mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
6e623ff9d2
commit
52013e5b6d
4 changed files with 32 additions and 15 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue