From 515b2ebb83484ae99fc99e9dbc51e5bceb9574be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20La=C3=BCgt?= Date: Thu, 17 Nov 2022 16:29:05 +0100 Subject: [PATCH] Fix logging errors: 'underlying buffer has been detached' (pypa#1631) --- setuptools/dist.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/setuptools/dist.py b/setuptools/dist.py index 82423548866..c5c4c8fdce8 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -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()