Skip to content

Commit

Permalink
Fix logging errors: 'underlying buffer has been detached' (pypa#1631)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlaugt committed Nov 17, 2022
1 parent a0e8e53 commit 515b2eb
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions setuptools/dist.py
Expand Up @@ -1195,19 +1195,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 515b2eb

Please sign in to comment.