| Index: third_party/cython/src/Cython/Utility/CommonTypes.c
|
| diff --git a/third_party/cython/src/Cython/Utility/CommonTypes.c b/third_party/cython/src/Cython/Utility/CommonTypes.c
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c2403cbf98a3d7e1bcda898ea9757ea41d7181cb
|
| --- /dev/null
|
| +++ b/third_party/cython/src/Cython/Utility/CommonTypes.c
|
| @@ -0,0 +1,48 @@
|
| +/////////////// FetchCommonType.proto ///////////////
|
| +
|
| +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
|
| +
|
| +/////////////// FetchCommonType ///////////////
|
| +
|
| +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
|
| + PyObject* fake_module;
|
| + PyTypeObject* cached_type = NULL;
|
| +
|
| + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
|
| + if (!fake_module) return NULL;
|
| + Py_INCREF(fake_module);
|
| +
|
| + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
|
| + if (cached_type) {
|
| + if (!PyType_Check((PyObject*)cached_type)) {
|
| + PyErr_Format(PyExc_TypeError,
|
| + "Shared Cython type %.200s is not a type object",
|
| + type->tp_name);
|
| + goto bad;
|
| + }
|
| + if (cached_type->tp_basicsize != type->tp_basicsize) {
|
| + PyErr_Format(PyExc_TypeError,
|
| + "Shared Cython type %.200s has the wrong size, try recompiling",
|
| + type->tp_name);
|
| + goto bad;
|
| + }
|
| + } else {
|
| + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
|
| + PyErr_Clear();
|
| + if (PyType_Ready(type) < 0) goto bad;
|
| + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
|
| + goto bad;
|
| + Py_INCREF(type);
|
| + cached_type = type;
|
| + }
|
| +
|
| +done:
|
| + Py_DECREF(fake_module);
|
| + // NOTE: always returns owned reference, or NULL on error
|
| + return cached_type;
|
| +
|
| +bad:
|
| + Py_XDECREF(cached_type);
|
| + cached_type = NULL;
|
| + goto done;
|
| +}
|
|
|