Permalink
Browse files

Fixed importing from submodules in Python 3

Thanks @benoitc for the report! Fixes #37
  • Loading branch information...
1 parent dd84204 commit b6e75e5f28ff9ff0d969415bfd434803bcc27edd @saghul committed Oct 15, 2012
Showing with 26 additions and 10 deletions.
  1. +2 −2 src/errno.c
  2. +24 −8 src/pyuv.c
View
@@ -45,7 +45,7 @@ Errno_methods[] = {
#ifdef PYUV_PYTHON3
-static PyModuleDef pyuv_errorno_module = {
+static PyModuleDef pyuv_errno_module = {
PyModuleDef_HEAD_INIT,
"pyuv.errno", /*m_name*/
NULL, /*m_doc*/
@@ -61,7 +61,7 @@ init_errno(void)
PyObject *module_dict;
PyObject *errorcode_dict;
#ifdef PYUV_PYTHON3
- module = PyModule_Create(&pyuv_errorno_module);
+ module = PyModule_Create(&pyuv_errno_module);
#else
module = Py_InitModule("pyuv.errno", Errno_methods);
#endif
View
@@ -61,8 +61,8 @@ init_pyuv(void)
PyObject *pyuv;
PyObject *errno_module;
PyObject *error_module;
- PyObject *fs;
- PyObject *util;
+ PyObject *fs_module;
+ PyObject *util_module;
/* Initialize GIL */
PyEval_InitThreads();
@@ -86,27 +86,43 @@ init_pyuv(void)
goto fail;
}
PyUVModule_AddObject(pyuv, "errno", errno_module);
+#ifdef PYUV_PYTHON3
+ PyDict_SetItemString(PyImport_GetModuleDict(), pyuv_errno_module.m_name, errno_module);
+ Py_DECREF(errno_module);
+#endif
/* Error module */
error_module = init_error();
if (error_module == NULL) {
goto fail;
}
PyUVModule_AddObject(pyuv, "error", error_module);
+#ifdef PYUV_PYTHON3
+ PyDict_SetItemString(PyImport_GetModuleDict(), pyuv_error_module.m_name, error_module);
+ Py_DECREF(error_module);
+#endif
/* FS module */
- fs = init_fs();
- if (fs == NULL) {
+ fs_module = init_fs();
+ if (fs_module == NULL) {
goto fail;
}
- PyUVModule_AddObject(pyuv, "fs", fs);
+ PyUVModule_AddObject(pyuv, "fs", fs_module);
+#ifdef PYUV_PYTHON3
+ PyDict_SetItemString(PyImport_GetModuleDict(), pyuv_fs_module.m_name, fs_module);
+ Py_DECREF(fs_module);
+#endif
/* Util module */
- util = init_util();
- if (util == NULL) {
+ util_module = init_util();
+ if (util_module == NULL) {
goto fail;
}
- PyUVModule_AddObject(pyuv, "util", util);
+ PyUVModule_AddObject(pyuv, "util", util_module);
+#ifdef PYUV_PYTHON3
+ PyDict_SetItemString(PyImport_GetModuleDict(), pyuv_util_module.m_name, util_module);
+ Py_DECREF(util_module);
+#endif
/* Types */
AsyncType.tp_base = &HandleType;

0 comments on commit b6e75e5

Please sign in to comment.