This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Rob Bairos
Recipients Rob Bairos
Date 2013-08-22.19:00:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1377198011.48.0.462132559828.issue18812@psf.upfronthosting.co.za>
In-reply-to
Content
Why does PyImport_Import (import.c) call __import__ then immediately discard the result, and then look for the module again in the module dictionary?  

It will return the same value in both cases no?

Ive included the relevant portion of the code below.
Its breaking an embedded application we've built where a hierarchy of modules are maintained outside the sys.modules dictionary.


 /* Call the __import__ function with the proper argument list
    Always use absolute import here.
    Calling for side-effect of import. */
 r = PyObject_CallFunction(import, "OOOOi", module_name, globals,
                           globals, silly_list, 0, NULL);
 if (r == NULL)
     goto err;

//-------------------------- WHY IS THIS SECTION NEEDED? --------
 Py_DECREF(r);
 modules = PyImport_GetModuleDict();
 r = PyDict_GetItem(modules, module_name);
 if (r != NULL)
//---------------------------------------------------------------
     Py_INCREF(r);
History
Date User Action Args
2013-08-22 19:00:11Rob Bairossetrecipients: + Rob Bairos
2013-08-22 19:00:11Rob Bairossetmessageid: <1377198011.48.0.462132559828.issue18812@psf.upfronthosting.co.za>
2013-08-22 19:00:11Rob Bairoslinkissue18812 messages
2013-08-22 19:00:11Rob Bairoscreate