Logged In: YES user_id=14198 Attaching a new patch that works perfectly. 2 checks remain in the code that will be debug only, but apart from that, it is pretty good. No changes at all to existing semantics. Tested on Linux and Windows.
Logged In: YES user_id=86307 It appears to me that PyAutoThreadState_Release calls PyThreadState_Clear after releasing the GIL (if the thread state was created by PyAutoThreadState_Ensure, then old state will be UNLOCKED, so PyEval_ReleaseThread will be called). It looks to me that, if the thread state is going to be deleted, the call to Clear it should be moved up to just before ReleaseThread, i.e.: if (oldstate == PyAutoThreadState_UNLOCKED) { if (tcur->autothreadstate_counter == 1) PyThreadState_Clear(tcur); PyEval_ReleaseThread(tcur); }
Logged In: YES user_id=14198 Checking in Include/pystate.h; new revision: 2.24; previous revision: 2.23 Checking in Include/pythread.h; new revision: 2.21; previous revision: 2.20 Checking in Lib/test/test_capi.py; new revision: 1.5; previous revision: 1.4 Checking in Modules/_testcapimodule.c; new revision: 1.22; previous revision: 1.21 Checking in Modules/posixmodule.c; new revision: 2.295; previous revision: 2.294 Checking in Python/ceval.c; new revision: 2.359; previous revision: 2.358 Checking in Python/pystate.c; new revision: 2.26; previous revision: 2.25 Checking in Python/pythonrun.c; new revision: 2.191; previous revision: 2.190 Checking in Python/thread.c; new revision: 2.46; previous revision: 2.45 Checking in Python/thread_sgi.h; new revision: 2.17; previous revision: 2.16