[Python-Dev] Peculiar import code in pickle.py (original) (raw)
Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Jul 13 20:34:37 CEST 2010
- Previous message: [Python-Dev] Peculiar import code in pickle.py
- Next message: [Python-Dev] Peculiar import code in pickle.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jul 13, 2010 at 1:57 PM, Benjamin Peterson <benjamin at python.org> wrote: ..
No! That's not recommended and a complete hack. The "dance" or importlib.importmodule is preferred.
Nevertheless, "a complete hack" is what PyImport_Import does:
PyObject * PyImport_Import(PyObject *module_name) { static PyObject silly_list = NULL; .. / Call the import function with the proper argument list * Always use absolute import here. */ r = PyObject_CallFunction(import, "OOOOi", module_name, globals, globals, silly_list, 0, NULL); .. }
and _pickle.c uses PyImport_Import() and thus is different form pickle.py which uses the double-lookup dance. As a result, the two implementations are subtly different. They cannot be both right. It should be easy to "fix" _pickle.c to do the sys.modules lookup, but I am not sure this is right.
- Previous message: [Python-Dev] Peculiar import code in pickle.py
- Next message: [Python-Dev] Peculiar import code in pickle.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]