From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7C25E158176 for ; Thu, 09 Oct 2025 05:33:24 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 5EC28340EC7 for ; Thu, 09 Oct 2025 05:33:24 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 529AF1102C9; Thu, 09 Oct 2025 05:33:23 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 45EE51102C9 for ; Thu, 09 Oct 2025 05:33:23 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F2D04340EC7 for ; Thu, 09 Oct 2025 05:33:22 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 63B2B2A94 for ; Thu, 09 Oct 2025 05:33:21 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1759987960.ef36e16b22c99440d58185216cb1e34cd610d338.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/util/__init__.py X-VCS-Directories: lib/portage/util/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ef36e16b22c99440d58185216cb1e34cd610d338 X-VCS-Branch: master Date: Thu, 09 Oct 2025 05:33:21 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2be2ebeb-ec21-4af9-81b3-4804732193c8 X-Archives-Hash: 4dc0b1c30a45ac7c3cd69b96d75329c8 commit: ef36e16b22c99440d58185216cb1e34cd610d338 Author: John R. Graham gentoo org> AuthorDate: Mon Aug 4 16:57:15 2025 +0000 Commit: Sam James gentoo org> CommitDate: Thu Oct 9 05:32:40 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ef36e16b writemsg: Use the proper base class TextIOBase instead of... ...StringIO for identifying all text I/O streams. When passing a regular text file descriptor to writemsg(), some bug-avoidance code was not identifying all of the file descriptor types that don't need Unicode encoding. The file descriptor was being tested for being an instance of io.StringIO instead of the base class for text streams (io.TextIOBase). As such, passing a file descriptor that was opened in the most natural way for a text file, for example fd = open(logfile, "w") writemsg("Hello, world!\n", fd=fd) would cause an exception because Unicode encoding would be applied unnecessarily, creating a binary object on which fd.write() would raise an exception. Signed-off-by: John R. Graham gentoo.org> Part-of: https://github.com/gentoo/portage/pull/1462 Closes: https://github.com/gentoo/portage/pull/1462 Signed-off-by: Sam James gentoo.org> lib/portage/util/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py index 50fa1680ff..55cd69c02e 100644 --- a/lib/portage/util/__init__.py +++ b/lib/portage/util/__init__.py @@ -112,7 +112,7 @@ def writemsg(mystr: str, noiselevel: int = 0, fd: Optional[TextIO] = None) -> No fd = sys.stderr if noiselevel <= noiselimit: # avoid potential UnicodeEncodeError - if isinstance(fd, io.StringIO): + if isinstance(fd, io.TextIOBase): mystr = _unicode_decode( mystr, encoding=_encodings["content"], errors="replace" )