Fix #331: Don't call Py_Initialize() in PyInit__jpype() to support Python 3.7#332
Fix #331: Don't call Py_Initialize() in PyInit__jpype() to support Python 3.7#332marscher merged 1 commit intojpype-project:masterfrom vstinner:patch-1
Conversation
…thon 3.7 Since Python 3.7, calling Py_Initialize() twice triggers a fatal error. Simply remove the Py_Initialize() call from PyInit__jpype(), since it is just useless.
|
cc @hroncok |
|
I tested manually https://github.com/konlpy/konlpy test suite with this JPype fix: Python doesn't crash anymore! My PR fixed my bug. |
|
I also reported the issue upstream: https://bugs.python.org/issue33932 |
|
cc @marscher Note: I'm a CPython core developer. |
|
I trust you and my CI, was just waiting for it to pass. Thank you very much for your patch! |
|
I guess we need to cut this jpype release soon... |
|
Does the PyEval_InitThreads() belong in the module initialization as well? The CPython documentation wasn't clear if this was a module thing or just part of the python startup. |
You have to keep this call. We enhanced the documentation in Python 3.7: Moreover, we did another change in Python 3.7: On Python 3.6 and older, it's a good thing to call this function to prevent race conditions when spawning threads in C which then uses the Python API. |
Oh, and if you are curious, I wrote an article about this specific change :-) https://vstinner.github.io/python37-gil-change.html |
|
That's very cool! Congrats for nailing this nasty one down 😎 |
|
@marscher We likely need to hit the known defect on the arrays considering everything with the same size as being directly convertible before cutting a release. But it will be a week or two before I can get back to that. |
|
While removing the Py_Initialize() is safe and fix a bug in Python 3.7rc1, FYI I fixed the future Python 3.7.0 final to allow again to call Py_Initialize() twice. But Nick Coghlan still plans to deprecate this behaviour, in the future calling Py_Initialize() twice will fail (as Python 3.7rc1). |
Since Python 3.7, calling Py_Initialize() twice triggers a fatal error.
Simply remove the Py_Initialize() call from PyInit__jpype(), since it is just useless.