-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-43682: @staticmethod inherits attributes #25268
Conversation
functools_wraps() call in cm_init() failed because Python didn't initialize PyClassMethod_Type type at startup. I created https://bugs.python.org/issue43770 to fix the issue: it's now fixed by df5dc1c |
I chose the following representation:
|
Static methods (@staticmethod) and class methods (@classmethod) now inherit the method attributes (__module__, __name__, __qualname__, __doc__, __annotations__) and have a new __wrapped__ attribute. Changes: * Add a repr() method to staticmethod and classmethod types. * Add tests on the @classmethod decorator.
…ethod` These attributes have all been added in Python 3.10+; see python/cpython#25268
@vstinner What’s this new |
It's a standard attribute added by |
@carljm Thanks, so I guess in this case it’s a documented duplicate of |
PyObject *value = PyObject_GetAttr(wrapped, name); | ||
if (value == NULL) { | ||
if (PyErr_ExceptionMatches(PyExc_AttributeError)) { | ||
PyErr_Clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use _PyObject_LookupAttr()
here. See #106303.
Static methods (@staticmethod) and class methods (@classmethod) now
inherit the method attributes (module, name, qualname,
doc, annotations) and have a new wrapped attribute.
Changes:
https://bugs.python.org/issue43682