Commit 7c96119f authored by Tres Seaver's avatar Tres Seaver Committed by GitHub

Merge pull request #57 from zopefoundation/py35-import-incompat

Work around AttributeError raised by Python 3.5.x.
parents f4531e4b fb38ed5a
......@@ -558,8 +558,18 @@ module_init(void)
cPersistenceCAPI = (cPersistenceCAPIstruct *)PyCObject_Import(
"persistent.cPersistence", "CAPI");
#endif
if (cPersistenceCAPI == NULL)
if (cPersistenceCAPI == NULL) {
/* The Capsule API attempts to import 'persistent' and then
* walk down to the specified attribute using getattr. If the C
* extensions aren't available, this can result in an
* AttributeError being raised. Let that percolate up as an
* ImportError so it can be caught in the expected way.
*/
if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_ImportError)) {
PyErr_SetString(PyExc_ImportError, "persistent C extension unavailable");
}
return NULL;
}
#ifdef PY3K
#define _SET_TYPE(typ) ((PyObject*)(&typ))->ob_type = &PyType_Type
......
......@@ -5,6 +5,10 @@
------------------
- Add support for Python 3.6.
- Raise an ``ImportError`` consistently on Python 3 if the C extension for
BTrees is used but the ``persistent`` C extension is not available.
Previously this could result in an odd ``AttributeError``. See
https://github.com/zopefoundation/BTrees/pull/55
4.4.0 (2017-01-11)
------------------
......
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