@@ -219,20 +219,30 @@ def test_no_docstring(self):
219219 with self .subTest (meth = meth , mtip = mtip ):
220220 self .assertEqual (get_spec (meth ), mtip )
221221
222- def test_attribute_exception (self ):
222+ def test_buggy_getattr_class (self ):
223223 class NoCall :
224- def __getattr__ (self , name ):
225- raise BaseException
224+ def __getattr__ (self , name ): # Not invoked for class attribute.
225+ raise IndexError # Bug.
226226 class CallA (NoCall ):
227- def __call__ (oui , a , b , c ):
227+ def __call__ (self , ci ): # Bug does not matter.
228228 pass
229229 class CallB (NoCall ):
230- def __call__ (self , ci ):
230+ def __call__ (oui , a , b , c ): # Non-standard 'self'.
231231 pass
232232
233233 for meth , mtip in ((NoCall , default_tip ), (CallA , default_tip ),
234- (NoCall (), '' ), (CallA (), '(a, b, c)' ),
235- (CallB (), '(ci)' )):
234+ (NoCall (), '' ), (CallA (), '(ci)' ),
235+ (CallB (), '(a, b, c)' )):
236+ with self .subTest (meth = meth , mtip = mtip ):
237+ self .assertEqual (get_spec (meth ), mtip )
238+
239+ def test_metaclass_class (self ): # Failure case for issue 38689.
240+ class Type (type ): # Type() requires 3 type args, returns class.
241+ __class__ = property ({}.__getitem__ , {}.__setitem__ )
242+ class Object (metaclass = Type ):
243+ __slots__ = '__class__'
244+ for meth , mtip in ((Type , default_tip ), (Object , default_tip ),
245+ (Object (), '' )):
236246 with self .subTest (meth = meth , mtip = mtip ):
237247 self .assertEqual (get_spec (meth ), mtip )
238248
0 commit comments