Commit 60ca7eb7 authored by da-woods's avatar da-woods Committed by GitHub

Avoid error if type doesn't have "__getstate__" when setting up pickle support. (GH-4739)

Fixes a bug introduced by https://github.com/cython/cython/commit/ae4ade8daeae206db68583f2f4b9c1cbce9cba75 for PyPy.
parent c24aa3d8
...@@ -216,7 +216,10 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { ...@@ -216,7 +216,10 @@ static int __Pyx_setup_reduce(PyObject* type_obj) {
#if CYTHON_USE_PYTYPE_LOOKUP #if CYTHON_USE_PYTYPE_LOOKUP
getstate = _PyType_Lookup((PyTypeObject*)type_obj, PYIDENT("__getstate__")); getstate = _PyType_Lookup((PyTypeObject*)type_obj, PYIDENT("__getstate__"));
#else #else
getstate = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__getstate__")); getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__getstate__"));
if (!getstate && PyErr_Occurred()) {
goto __PYX_BAD;
}
#endif #endif
if (getstate) { if (getstate) {
// Python 3.11 introduces object.__getstate__. Because it's version-specific failure to find it should not be an error // Python 3.11 introduces object.__getstate__. Because it's version-specific failure to find it should not be an error
...@@ -224,6 +227,9 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { ...@@ -224,6 +227,9 @@ static int __Pyx_setup_reduce(PyObject* type_obj) {
object_getstate = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__getstate__")); object_getstate = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__getstate__"));
#else #else
object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, PYIDENT("__getstate__")); object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, PYIDENT("__getstate__"));
if (!object_getstate && PyErr_Occurred()) {
goto __PYX_BAD;
}
#endif #endif
if (object_getstate != getstate) { if (object_getstate != getstate) {
goto __PYX_GOOD; goto __PYX_GOOD;
......
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