diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-21 15:20:53 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-21 15:20:53 +0200 |
commit | c2327bfd89492ce2434cab161ed4c2df83b47b48 (patch) | |
tree | 354500ad1e5a10f4a435afa36e9c81db230d98e7 | |
parent | 59de323f70e659761db810bd5c51aad23c7ec96b (diff) | |
download | cython-c2327bfd89492ce2434cab161ed4c2df83b47b48.tar.gz |
Another PyPy2 fix.
-rw-r--r-- | Cython/Utility/ObjectHandling.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c index 08985e49c..5140030db 100644 --- a/Cython/Utility/ObjectHandling.c +++ b/Cython/Utility/ObjectHandling.c @@ -1082,8 +1082,12 @@ static int __Pyx_SetNamesPEP487(PyObject *type_obj) { PyObject *d = PyObject_GetAttr(type_obj, PYIDENT("__dict__")); names_to_set = NULL; if (likely(d)) { - names_to_set = PyDict_Copy(d); + // d may not be a dict, e.g. PyDictProxy in PyPy2. + PyObject *names_to_set = PyDict_New(); + int ret = likely(names_to_set) ? PyDict_Update(names_to_set, d) : -1; Py_DECREF(d); + if (unlikely(ret < 0)) + Py_CLEAR(names_to_set); } } #endif |