summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-01-10 07:30:43 (GMT)
committerGitHub <noreply@github.com>2021-01-10 07:30:43 (GMT)
commit799f8489d418b7f9207d333eac38214931bd7dcc (patch)
treeb665d91766509be337f4deba74a16f91a778cbd4 /Lib/idlelib/idle_test
parent9ab4dd452287169f08a8cf4d4c68c2139f8de714 (diff)
downloadcpython-799f8489d418b7f9207d333eac38214931bd7dcc.zip
cpython-799f8489d418b7f9207d333eac38214931bd7dcc.tar.gz
cpython-799f8489d418b7f9207d333eac38214931bd7dcc.tar.bz2
bpo-33065: Fix problem debugging user classes with __repr__ method (GH-24183)
If __repr__ uses instance attributes, as normal, and one steps through the __init__ method, debugger may try to get repr before the instance attributes exist. reprlib.repr handles the error. (cherry picked from commit 81f87bbf9f65702062021a78abd9b8f82c98a414) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_debugger_r.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/idlelib/idle_test/test_debugger_r.py b/Lib/idlelib/idle_test/test_debugger_r.py
index 199f634..638ebd3 100644
--- a/Lib/idlelib/idle_test/test_debugger_r.py
+++ b/Lib/idlelib/idle_test/test_debugger_r.py
@@ -25,5 +25,19 @@ class Test(unittest.TestCase):
# Classes GUIProxy, IdbAdapter, FrameProxy, CodeProxy, DictProxy,
# GUIAdapter, IdbProxy plus 7 module functions.
+class IdbAdapterTest(unittest.TestCase):
+
+ def test_dict_item_noattr(self): # Issue 33065.
+
+ class BinData:
+ def __repr__(self):
+ return self.length
+
+ debugger_r.dicttable[0] = {'BinData': BinData()}
+ idb = debugger_r.IdbAdapter(None)
+ self.assertTrue(idb.dict_item(0, 'BinData'))
+ debugger_r.dicttable.clear()
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)