[issue26154] Add private _PyThreadState_UncheckedGet() to get the current thread state

Wenzel Jakob report at bugs.python.org
Mon Apr 25 11:16:37 EDT 2016


Wenzel Jakob added the comment:

I've also run into this regression. FWIW this is what I've ended up using to work around it (it's a mess, but what are we to do..)

#if PY_VERSION_HEX >= 0x03050000 && PY_VERSION_HEX < 0x03050200
extern "C" {
    /* Manually import _PyThreadState_Current symbol */
    struct _Py_atomic_address { void *value; };
    PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
};
#endif

PyThreadState *get_thread_state_unchecked() {
#if   PY_VERSION_HEX < 0x03000000
    return _PyThreadState_Current;
#elif PY_VERSION_HEX < 0x03050000
    return (PyThreadState*) _Py_atomic_load_relaxed(&_PyThreadState_Current);
#elif PY_VERSION_HEX < 0x03050200
    return (PyThreadState*) _PyThreadState_Current.value;
#else
    return _PyThreadState_UncheckedGet();
#endif
}

----------
nosy: +wenzel

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26154>
_______________________________________


More information about the Python-bugs-list mailing list