This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mauvilsa
Recipients gvanrossum, mauvilsa
Date 2021-07-14.15:24:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Doesn’t it do that with any built in function?

Sorry. I did not include what is the behavior for other classes. An example could be calendar.Calendar. In this case the signature gives:

>>> from calendar import Calendar
>>> import inspect
>>> print(inspect.signature(Calendar.__init__))
(self, firstweekday=0)
>>> print(inspect.signature(Calendar))

Note that the signature gives firstweekday which is the only init parameter. Calendar is not implemented with __new__ so getting the signature would be for object, that does not include named parameters.

It also works fine when you implement a class with __new__. For example:

>>> class MyClass:
    def __new__(cls, paramA, paramB=1):
        obj = object.__new__(cls)
        obj.paramA = paramA
        obj.paramB = paramB
        return obj
>>> print(inspect.signature(MyClass.__new__))
(cls, paramA, paramB=1)
>>> print(inspect.signature(MyClass))
(paramA, paramB=1)

I do think it is a bug specific to the datetime classes.
Date User Action Args
2021-07-14 15:24:08mauvilsasetrecipients: + mauvilsa, gvanrossum
2021-07-14 15:24:08mauvilsasetmessageid: <>
2021-07-14 15:24:08mauvilsalinkissue44618 messages
2021-07-14 15:24:08mauvilsacreate