From 9b5a31f49dc1a9210405bbdd30c85a34ecf9c4b8 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 1/2] Fix logging errors: 'underlying buffer has been detached' --- setuptools/dist.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/setuptools/dist.py b/setuptools/dist.py index 8242354886..c5c4c8fdce 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() From ff7aee65072335b0a6173b3c03e8f657dfa6a1e1 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 23 Nov 2022 14:04:44 +0000 Subject: [PATCH 2/2] Add news fragment --- changelog.d/3690.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3690.misc.rst diff --git a/changelog.d/3690.misc.rst b/changelog.d/3690.misc.rst new file mode 100644 index 0000000000..388bd0b12a --- /dev/null +++ b/changelog.d/3690.misc.rst @@ -0,0 +1 @@ +Fixed logging errors: 'underlying buffer has been detached' (issue #1631).