Title: PyEval_InitThreads() not safe before Py_Initialize()
Type: behavior Stage: resolved
Components: Documentation, Interpreter Core Versions: Python 3.2, Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Juraj.Ivancic, amaury.forgeotdarc, docs@python, gliktaras, pitrou, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2011-02-26 09:49 by Juraj.Ivancic, last changed 2011-03-13 22:30 by pitrou. This issue is now closed.

File name Uploaded Description Edit
issue11329-1.patch gliktaras, 2011-03-12 21:07 review
Messages (6)
msg129515 - (view) Author: Juraj Ivancic (Juraj.Ivancic) * Date: 2011-02-26 09:49
It seems that PyEval_InitThreads() can no longer be called before
Py_Initialize(). I get a fatal error in PyThreadState_GET().
This contradicts the documentation

Minimal repro:

#include "Python.h"
int main()
     return 0;

Everything works if Py_Initialize() is called first.
msg129517 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-02-26 10:01
Given the way the new GIL works, I'm afraid it's not really possible to support this (it needs some thread-state to be available).
Note that there is no reason, AFAIK, why you would want to call PyEval_InitThreads() before Py_Initialize().
msg129628 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-02-27 14:35
Can you write a patch for the documentation?
msg130697 - (view) Author: Gediminas Liktaras (gliktaras) Date: 2011-03-12 21:07
I have attached a patch that fixes this issue. Please let me know if there are any problems.
msg130771 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-13 22:29
New changeset 4c59cd84086f by Antoine Pitrou in branch '3.2':
Issue #11329: PyEval_InitThreads() cannot be called before Py_Initialize() anymore

New changeset 3c0edb157ea2 by Antoine Pitrou in branch 'default':
Issue #11329: PyEval_InitThreads() cannot be called before Py_Initialize() anymore
msg130772 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-13 22:30
Patch now committed, thank you!
Date User Action Args
2011-03-13 22:30:40pitrousetstatus: open -> closed
nosy: amaury.forgeotdarc, pitrou, vstinner, docs@python, Juraj.Ivancic, python-dev, gliktaras
messages: + msg130772

resolution: fixed
stage: resolved
2011-03-13 22:29:33python-devsetnosy: + python-dev
messages: + msg130771
2011-03-12 21:07:58gliktarassetfiles: + issue11329-1.patch

nosy: + gliktaras
messages: + msg130697

keywords: + patch
2011-02-27 14:35:20vstinnersetnosy: amaury.forgeotdarc, pitrou, vstinner, docs@python, Juraj.Ivancic
messages: + msg129628
2011-02-27 14:35:07vstinnersetnosy: + vstinner
2011-02-26 10:01:53pitrousetassignee: docs@python
type: crash -> behavior
components: + Documentation
versions: + Python 3.3
nosy: + amaury.forgeotdarc, docs@python, pitrou

messages: + msg129517
2011-02-26 09:49:51Juraj.Ivanciccreate