Commit db7d8c7c authored by Stefan Behnel's avatar Stefan Behnel

fix some PyPy glitches in __Pyx_Globals()

parent 66aa9874
...@@ -13,7 +13,7 @@ static PyObject* __Pyx_Globals(void); /*proto*/ ...@@ -13,7 +13,7 @@ static PyObject* __Pyx_Globals(void); /*proto*/
static PyObject* __Pyx_Globals(void) { static PyObject* __Pyx_Globals(void) {
Py_ssize_t i; Py_ssize_t i;
/*PyObject *d;*/ //PyObject *d;
PyObject *names = NULL; PyObject *names = NULL;
PyObject *globals = PyObject_GetAttrString($module_cname, "__dict__"); PyObject *globals = PyObject_GetAttrString($module_cname, "__dict__");
if (!globals) { if (!globals) {
...@@ -24,17 +24,33 @@ static PyObject* __Pyx_Globals(void) { ...@@ -24,17 +24,33 @@ static PyObject* __Pyx_Globals(void) {
names = PyObject_Dir($module_cname); names = PyObject_Dir($module_cname);
if (!names) if (!names)
goto bad; goto bad;
for (i = 0; i < PyList_GET_SIZE(names); i++) { for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
#if CYTHON_COMPILING_IN_PYPY
PyObject* name = PySequence_GetItem(names, i);
if (!name)
goto bad;
#else
PyObject* name = PyList_GET_ITEM(names, i); PyObject* name = PyList_GET_ITEM(names, i);
#endif
if (!PyDict_Contains(globals, name)) { if (!PyDict_Contains(globals, name)) {
PyObject* value = PyObject_GetAttr($module_cname, name); PyObject* value = PyObject_GetAttr($module_cname, name);
if (!value) if (!value) {
#if CYTHON_COMPILING_IN_PYPY
Py_DECREF(name);
#endif
goto bad; goto bad;
}
if (PyDict_SetItem(globals, name, value) < 0) { if (PyDict_SetItem(globals, name, value) < 0) {
#if CYTHON_COMPILING_IN_PYPY
Py_DECREF(name);
#endif
Py_DECREF(value); Py_DECREF(value);
goto bad; goto bad;
} }
} }
#if CYTHON_COMPILING_IN_PYPY
Py_DECREF(name);
#endif
} }
Py_DECREF(names); Py_DECREF(names);
return globals; return globals;
......
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