Commit 34f656d0 authored by Stefan Behnel's avatar Stefan Behnel

add a warning if patching collections.abc.Generator fails

parent baef96df
...@@ -830,14 +830,19 @@ static int __Pyx_patch_abc(void) { ...@@ -830,14 +830,19 @@ static int __Pyx_patch_abc(void) {
static int abc_patched = 0; static int abc_patched = 0;
if (!abc_patched) { if (!abc_patched) {
PyObject *module; PyObject *module;
module = PyImport_ImportModule("collections.abc"); module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
if (!module) { if (!module) {
PyErr_Clear(); PyErr_WriteUnraisable(NULL);
module = PyImport_ImportModule("collections"); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch "
if (!module) #if PY_MAJOR_VERSION >= 3
PyErr_Clear(); "collections.abc.Generator"
#else
"collections.Generator"
#endif
, 1) < 0)) {
return -1;
} }
if (module) { } else {
PyObject *abc = PyObject_GetAttrString(module, "Generator"); PyObject *abc = PyObject_GetAttrString(module, "Generator");
if (abc) { if (abc) {
abc_patched = 1; abc_patched = 1;
......
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