[issue13577] __qualname__ is not present on builtin methods and functions

Antoine Pitrou report at bugs.python.org
Wed Dec 21 11:35:17 CET 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

Thanks for the patch. Since you modified PyCFunction_GET_SELF to return NULL for static methods, why not simply use it instead of manually looking up the flags in several places?

I'm talking about the following changes:

-    PyObject *self = PyCFunction_GET_SELF(func);
+    int flags = PyCFunction_GET_FLAGS(func);
+    PyObject *self = flags & METH_STATIC ? NULL :
+        _PyCFunction_GET_RAW_SELF(func);

[...]

     self = m->m_self;
-    if (self == NULL)
+    if (self == NULL || PyCFunction_GET_FLAGS(m) & METH_STATIC)
         self = Py_None;

[...]

-            PyObject *self = PyCFunction_GET_SELF(func);
+            PyObject *self = flags & METH_STATIC ? NULL :
+                _PyCFunction_GET_RAW_SELF(func);


Unless you demonstrate there's a significant performance improvement in this style, we should really favour the simpler style.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13577>
_______________________________________


More information about the Python-bugs-list mailing list