| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
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 |
Sorry, something went wrong.
|
I chose the following representation: $ ./python -q >>> def func(): pass ... >>> staticmethod(func) <staticmethod(<function func at 0x7f39e8152c50>)> >>> classmethod(func) <classmethod(<function func at 0x7f39e8152c50>)> |
Sorry, something went wrong.
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.
Sorry, something went wrong.
…ethod` These attributes have all been added in Python 3.10+; see python/cpython#25268
|
@vstinner What’s this new __wrapped__ attribute? Is it the same as the existing __func__ attribute? If so, why did you introduce it? |
Sorry, something went wrong.
It's a standard attribute added by functools.wraps to wrapper functions allowing unwrapping back to the wrapped function (eg by inspect.unwrap). So it's generally useful for wrappers to set it. |
Sorry, something went wrong.
|
@carljm Thanks, so I guess in this case it’s a documented duplicate of __func__ which is an undocumented attribute. |
Sorry, something went wrong.
| PyObject *value = PyObject_GetAttr(wrapped, name); | ||
| if (value == NULL) { | ||
| if (PyErr_ExceptionMatches(PyExc_AttributeError)) { | ||
| PyErr_Clear(); |
There was a problem hiding this comment.
It is better to use _PyObject_LookupAttr() here. See #106303.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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