https://github.com/python/cpython/commit/149562e46f161b9da1dec0d20a87fefdaf0f0eea
commit: 149562e46f161b9da1dec0d20a87fefdaf0f0eea
branch: main
author: PavlNekrasov <[email protected]>
committer: terryjreedy <[email protected]>
date: 2026-11-06T18:00:04-05:00
summary:
gh-161477: Fix single-element tuple in idlelib redirector `__repr__` (#161481)
Result is mangled repr(). Extremely unlikely to be seen by IDLE users, but
idlelib maintainers might if internal error.
files:
A Misc/NEWS.d/next/IDLE/2026-11-06-17-12-40.gh-issue-161477.smXIKC.rst
M Lib/idlelib/idle_test/test_redirector.py
M Lib/idlelib/redirector.py
diff --git a/Lib/idlelib/idle_test/test_redirector.py
b/Lib/idlelib/idle_test/test_redirector.py
index bd486d7da660108..58e7775071c19c1 100644
--- a/Lib/idlelib/idle_test/test_redirector.py
+++ b/Lib/idlelib/idle_test/test_redirector.py
@@ -64,8 +64,10 @@ def tearDown(self):
self.redir.close()
def test_repr(self): # partly for 100% coverage
- self.assertIn('Redirector', repr(self.redir))
- self.assertIn('Original', repr(self.orig_insert))
+ self.assertEqual(repr(self.redir),
+ f"WidgetRedirector(Text<{self.text._w}>)")
+ self.assertEqual(repr(self.orig_insert),
+ f"OriginalCommand({self.redir!r}, 'insert')")
def test_register(self):
self.assertEqual(self.text.get('1.0', 'end'), '\n')
diff --git a/Lib/idlelib/redirector.py b/Lib/idlelib/redirector.py
index 8e2ba68d3815bf0..821a45ee7982a47 100644
--- a/Lib/idlelib/redirector.py
+++ b/Lib/idlelib/redirector.py
@@ -48,7 +48,7 @@ def __init__(self, widget):
def __repr__(self):
w = self.widget
- return f"{self.__class__.__name__,}({w.__class__.__name__}<{w._w}>)"
+ return f"{self.__class__.__name__}({w.__class__.__name__}<{w._w}>)"
def close(self):
"Unregister operations and revert redirection created by .__init__."
@@ -143,7 +143,7 @@ def __init__(self, redir, operation):
self.orig_and_operation = (redir.orig, operation)
def __repr__(self):
- return f"{self.__class__.__name__,}({self.redir!r},
{self.operation!r})"
+ return f"{self.__class__.__name__}({self.redir!r}, {self.operation!r})"
def __call__(self, *args):
return self.tk_call(self.orig_and_operation + args)
diff --git
a/Misc/NEWS.d/next/IDLE/2026-11-06-17-12-40.gh-issue-161477.smXIKC.rst
b/Misc/NEWS.d/next/IDLE/2026-11-06-17-12-40.gh-issue-161477.smXIKC.rst
new file mode 100644
index 000000000000000..ca955e608bc8936
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2026-11-06-17-12-40.gh-issue-161477.smXIKC.rst
@@ -0,0 +1,3 @@
+Fix ``repr()`` of ``idlelib.redirector.WidgetRedirector`` and
+``idlelib.redirector.OriginalCommand``, which displayed a spurious
+one-element tuple.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]