A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-July/101899.html below:

[Python-Dev] Peculiar import code in pickle.py

[Python-Dev] Peculiar import code in pickle.pyAlexander Belopolsky alexander.belopolsky at gmail.com
Tue Jul 13 20:34:37 CEST 2010
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.import_module 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.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4