summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorTal Einat <taleinat+github@gmail.com>2020-04-04 03:05:58 (GMT)
committerGitHub <noreply@github.com>2020-04-04 03:05:58 (GMT)
commit52013e5b6d5ca32eef5a3d65ecdf7db89cefc2fd (patch)
treeb66ad6b00c4ecd03f18bd951d0952ab728f794f9 /Lib/idlelib/idle_test
parent6e623ff9d251e0ce86e9b18a01bfd6f067079d7a (diff)
downloadcpython-52013e5b6d5ca32eef5a3d65ecdf7db89cefc2fd.zip
cpython-52013e5b6d5ca32eef5a3d65ecdf7db89cefc2fd.tar.gz
cpython-52013e5b6d5ca32eef5a3d65ecdf7db89cefc2fd.tar.bz2
bpo-38689: avoid IDLE hanging when calltip fails getting a signature (GH-17152)
Inspect.signature failed on the test case because its isinstance call raised.
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_calltip.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/idlelib/idle_test/test_calltip.py b/Lib/idlelib/idle_test/test_calltip.py
index 886959b..d386b5c 100644
--- a/Lib/idlelib/idle_test/test_calltip.py
+++ b/Lib/idlelib/idle_test/test_calltip.py
@@ -219,20 +219,30 @@ bytes() -> empty bytes object''')
with self.subTest(meth=meth, mtip=mtip):
self.assertEqual(get_spec(meth), mtip)
- def test_attribute_exception(self):
+ def test_buggy_getattr_class(self):
class NoCall:
- def __getattr__(self, name):
- raise BaseException
+ def __getattr__(self, name): # Not invoked for class attribute.
+ raise IndexError # Bug.
class CallA(NoCall):
- def __call__(oui, a, b, c):
+ def __call__(self, ci): # Bug does not matter.
pass
class CallB(NoCall):
- def __call__(self, ci):
+ def __call__(oui, a, b, c): # Non-standard 'self'.
pass
for meth, mtip in ((NoCall, default_tip), (CallA, default_tip),
- (NoCall(), ''), (CallA(), '(a, b, c)'),
- (CallB(), '(ci)')):
+ (NoCall(), ''), (CallA(), '(ci)'),
+ (CallB(), '(a, b, c)')):
+ with self.subTest(meth=meth, mtip=mtip):
+ self.assertEqual(get_spec(meth), mtip)
+
+ def test_metaclass_class(self): # Failure case for issue 38689.
+ class Type(type): # Type() requires 3 type args, returns class.
+ __class__ = property({}.__getitem__, {}.__setitem__)
+ class Object(metaclass=Type):
+ __slots__ = '__class__'
+ for meth, mtip in ((Type, default_tip), (Object, default_tip),
+ (Object(), '')):
with self.subTest(meth=meth, mtip=mtip):
self.assertEqual(get_spec(meth), mtip)