Commit 2ffd5060 authored by Jeroen Demeyer's avatar Jeroen Demeyer Committed by Stefan Behnel

__Pyx_GetNameInClass() should get raw attribute from __dict__ (GH-3100)

parent 3ac72f5f
......@@ -1180,18 +1180,27 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/
/////////////// GetNameInClass ///////////////
//@requires: PyObjectGetAttrStrNoError
//@requires: GetModuleGlobalName
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
PyObject *result;
result = __Pyx_PyObject_GetAttrStrNoError(nmspace, name);
if (!result) {
if (unlikely(PyErr_Occurred()))
return NULL;
__Pyx_GetModuleGlobalNameUncached(result, name);
return result;
PyObject *dict;
assert(PyType_Check(nmspace));
#if CYTHON_USE_TYPE_SLOTS
dict = ((PyTypeObject*)nmspace)->tp_dict;
Py_XINCREF(dict);
#else
dict = PyObject_GetAttr(nmspace, PYIDENT("__dict__"));
#endif
if (likely(dict)) {
result = PyObject_GetItem(dict, name);
Py_DECREF(dict);
if (result) {
return result;
}
}
PyErr_Clear();
__Pyx_GetModuleGlobalNameUncached(result, name);
return result;
}
......
cdef class Foo:
"""
>>> D = Foo.__dict__
>>> D["meth"] is D["meth2"]
True
>>> D["classmeth"] is D["classmeth2"]
True
>>> D["staticmeth"] is D["staticmeth2"]
True
"""
def meth(self): pass
@classmethod
def classmeth(cls): pass
@staticmethod
def staticmeth(): pass
meth2 = meth
classmeth2 = classmeth
staticmeth2 = staticmeth
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment