Why do I need to call PyImport_AppendInittab () before Py_Initialize ()?

According to the documentation , PyImport_AppendInittab "should be called before Py_Initialize ()."

There is no explanation why this is so, and ignoring this advice gives a working application. So, since it works, under what circumstances will it not work?

Regards, Daniel

+4
source share
1 answer

Because in the documentation it is; and a violation of the API can give a working application today, but not tomorrow.

A few problems you may encounter:

  • sys.builtin_module_names initialized inside Py_Initialize , so it will not contain your module
  • PyImport_AppendInittab does not accept any locks, so if you call it after Py_Initialize in a multi-threaded application, you may get memory corruption.
+4
source

Source: https://habr.com/ru/post/1432299/


All Articles