Skip to content

Commit

Permalink
Fix logging errors - underlying buffer has been detached (#3690)
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Nov 23, 2022
2 parents 917b761 + ff7aee6 commit 07cd680
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.d/3690.misc.rst
@@ -0,0 +1 @@
Fixed logging errors: 'underlying buffer has been detached' (issue #1631).
12 changes: 2 additions & 10 deletions setuptools/dist.py
Expand Up @@ -1194,19 +1194,11 @@ def handle_display_options(self, option_order):

# Print metadata in UTF-8 no matter the platform
encoding = sys.stdout.encoding
errors = sys.stdout.errors
newline = sys.platform != 'win32' and '\n' or None
line_buffering = sys.stdout.line_buffering

sys.stdout = io.TextIOWrapper(
sys.stdout.detach(), 'utf-8', errors, newline, line_buffering
)
sys.stdout.reconfigure(encoding='utf-8')
try:
return _Distribution.handle_display_options(self, option_order)
finally:
sys.stdout = io.TextIOWrapper(
sys.stdout.detach(), encoding, errors, newline, line_buffering
)
sys.stdout.reconfigure(encoding=encoding)

def run_command(self, command):
self.set_defaults()
Expand Down

0 comments on commit 07cd680

Please sign in to comment.