diff -r ffe1d684b41e Lib/inspect.py --- a/Lib/inspect.py Mon Jan 27 15:07:58 2014 -0500 +++ b/Lib/inspect.py Mon Jan 27 16:07:09 2014 -0500 @@ -1534,6 +1534,17 @@ init = _get_user_defined_method(obj, '__init__') if init is not None: sig = signature(init) + + if sig is None: + if type in obj.__mro__: + # 'obj' is a metaclass without user-defined __init__ + # or __new__. Return a signature of 'type' builtin. + return signature(type) + else: + # We have a class (not metaclass), but no user-defined + # __init__ or __new__ for it + return signature(object) + elif not isinstance(obj, _NonUserDefinedCallables): # An object with __call__ # We also check that the 'obj' is not an instance of diff -r ffe1d684b41e Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Mon Jan 27 15:07:58 2014 -0500 +++ b/Lib/test/test_inspect.py Mon Jan 27 16:07:09 2014 -0500 @@ -2018,6 +2018,20 @@ ('bar', 2, ..., "keyword_only")), ...)) + # Test classes without user-defined __init__ or __new__ + class C: pass + self.assertEqual(str(inspect.signature(C)), '()') + class D(C): pass + self.assertEqual(str(inspect.signature(D)), '()') + + # Test meta-classes without user-defined __init__ or __new__ + class C(type): pass + self.assertEqual(str(inspect.signature(C)), + '(object_or_name, bases, dict)') + class D(C): pass + self.assertEqual(str(inspect.signature(D)), + '(object_or_name, bases, dict)') + def test_signature_on_callable_objects(self): class Foo: def __call__(self, a):