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 thomas.perl
Recipients thomas.perl
Date 2017-06-03.19:15:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496517343.89.0.835339034855.issue30560@psf.upfronthosting.co.za>
In-reply-to
Content
In our application that embeds a Python interpreter, we had the issue that certain system configurations (namely, a lone "libpython27.dll" without any standard library) caused silent failures (note that this is using Python 2.7, but Python 3.x would be similarly affected, as the Py_FatalError() handling is still the same):

https://github.com/gpodder/gpodder/issues/286

There exists a Stack Overflow thread about this:

https://stackoverflow.com/questions/7688374/how-to-i-catch-and-handle-a-fatal-error-when-py-initialize-fails

The workaround described therein is:

"I solved this by creating a separate executable that attempts to initialize python. My primary process will launch it and check the exit code and only call PyInitialize if the child process was successful. So, python is initialized twice, but it is better than an apparent crash to the user."

So, what if instead we allow the embedding program to set a function pointer to a function that will get called instead of abort()? We have to make clear in the docs that after this function is called, the Python interpreter cannot be used, and the application should probably exit, but at least it would allow applications to capture the error message and show it to the user (e.g. using a MessageBox() on Windows) before exiting -- see attached patch.

Any alternative solutions would be fine as well that don't require us to create a new process and "try to" Py_Initialize() there, especially since Py_FatalError() might potentially be called in other places and in all those cases, a user-visible dialog would be better than an apparent "crash" (application exits).
History
Date User Action Args
2017-06-03 19:15:43thomas.perlsetrecipients: + thomas.perl
2017-06-03 19:15:43thomas.perlsetmessageid: <1496517343.89.0.835339034855.issue30560@psf.upfronthosting.co.za>
2017-06-03 19:15:43thomas.perllinkissue30560 messages
2017-06-03 19:15:43thomas.perlcreate