Message168261
| Author |
scoder |
| Recipients |
Arfrever, brett.cannon, eric.snow, georg.brandl, meador.inge, scoder |
| Date |
2012年08月15日.06:15:43 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1345011344.2.0.287140564082.issue15623@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I tried it and it works to just insert the package module into sys.modules after creation if it's not there yet:
#if PY_MAJOR_VERSION < 3
__pyx_m = Py_InitModule4(__Pyx_NAMESTR("my_test_package"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
#else
__pyx_m = PyModule_Create(&__pyx_moduledef);
#endif
if (!__pyx_m) {...};
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {...}
if (!PyDict_GetItemString(modules, "my_test_package"))
if (unlikely(PyDict_SetItemString(modules, "my_test_package", __pyx_m) < 0)) {...}
So this is a work-around that we can use in Cython in any case. |
|