[Python-Dev] embedding - PyImport_AppendInittab() after Py_Initialize() (original) (raw)

Brett Cannon brett at python.org
Mon May 30 17:59:29 EDT 2016


On Fri, 27 May 2016 at 07:50 Vitaly Murashev <vitaly.murashev at gmail.com> wrote:

Could anyone please clarify whether it is correct in python3.5 to call PyImportAppendInittab() after PyInitialize()

It should be called before as PyImport_AppendInittab() is shorthand for PyImport_ExtendInittab() and it says to call prior to Py_Initialize(): https://github.com/python/cpython/blob/f680b517e2701e9a3859afb62628a46eccdce17c/Python/import.c#L2153 .

-Brett

I found this case among the tests for boost.python https://github.com/boostorg/python/blob/develop/test/exec.cpp And this test doesn't work for me with python3.5.An error looks like: _exec.cpp(137): Python Error detected in function 'void cdecl checkpyerr(bool)' Traceback (most recent call last): File "", line 1, in ImportError: 'embeddedhello' is not a built-in module 1 error detected. After debugging I found out that root cause is in importlib/bootstrap.py which do the following: if fullname not in sys.builtinmodulenames: raise ImportError('{!r} is not a built-in module'.format(fullname), name=fullname) but sys.builtinmodulenames is the constant which initialized once in PyInitialize() --- To summarize: Is it a bug in python3.5 or original test inside boost.python should be fixed ?


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/brett%40python.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160530/54b50cd9/attachment.html>



More information about the Python-Dev mailing list