python: Fix import.
authorJustus Winter <justus@gnupg.org>
Thu, 19 May 2016 08:49:43 +0000 (10:49 +0200)
committerJustus Winter <justus@gnupg.org>
Thu, 19 May 2016 09:09:45 +0000 (11:09 +0200)
* lang/python/helpers.c (pygpgme_exception_init): Make module import
relative.

Signed-off-by: Justus Winter <justus@gnupg.org>
lang/python/helpers.c

index 96c844f..285b1da 100644 (file)
@@ -29,7 +29,10 @@ static PyObject *GPGMEError = NULL;
 void pygpgme_exception_init(void) {
   if (GPGMEError == NULL) {
     PyObject *errors;
-    errors = PyImport_ImportModule("errors");
+    PyObject *from_list = PyList_New(0);
+    errors = PyImport_ImportModuleLevel("errors", PyEval_GetGlobals(),
+                                        PyEval_GetLocals(), from_list, 1);
+    Py_XDECREF(from_list);
     if (errors) {
       GPGMEError=PyDict_GetItemString(PyModule_GetDict(errors), "GPGMEError");
       Py_XINCREF(GPGMEError);