summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-20 10:12:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-20 10:12:38 (GMT)
commitbfd316e750bc3040c08d1b5872e2de188e8c1e5f (patch)
treea0f5fc0ce8c171cd2b1f875c33b6089471c07447 /Objects/dictobject.c
parentaebb6d3682e08c93d8468a9291180c5cbdc2df1b (diff)
downloadcpython-bfd316e750bc3040c08d1b5872e2de188e8c1e5f.zip
cpython-bfd316e750bc3040c08d1b5872e2de188e8c1e5f.tar.gz
cpython-bfd316e750bc3040c08d1b5872e2de188e8c1e5f.tar.bz2
Add _PyThreadState_UncheckedGet()
Issue #26154: Add a new private _PyThreadState_UncheckedGet() function which gets the current thread state, but don't call Py_FatalError() if it is NULL. Python 3.5.1 removed the _PyThreadState_Current symbol from the Python C API to no more expose complex and private atomic types. Atomic types depends on the compiler or can even depend on compiler options. The new function _PyThreadState_UncheckedGet() allows to get the variable value without having to care of the exact implementation of atomic types. Changes: * Replace direct usage of the _PyThreadState_Current variable with a call to _PyThreadState_UncheckedGet(). * In pystate.c, replace direct usage of the _PyThreadState_Current variable with the PyThreadState_GET() macro for readability. * Document also PyThreadState_Get() in pystate.h
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 9a30fa8..8523511 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1064,8 +1064,7 @@ PyDict_GetItem(PyObject *op, PyObject *key)
Let's just hope that no exception occurs then... This must be
_PyThreadState_Current and not PyThreadState_GET() because in debug
mode, the latter complains if tstate is NULL. */
- tstate = (PyThreadState*)_Py_atomic_load_relaxed(
- &_PyThreadState_Current);
+ tstate = _PyThreadState_UncheckedGet();
if (tstate != NULL && tstate->curexc_type != NULL) {
/* preserve the existing exception */
PyObject *err_type, *err_value, *err_tb;
@@ -1102,8 +1101,7 @@ _PyDict_GetItem_KnownHash(PyObject *op, PyObject *key, Py_hash_t hash)
Let's just hope that no exception occurs then... This must be
_PyThreadState_Current and not PyThreadState_GET() because in debug
mode, the latter complains if tstate is NULL. */
- tstate = (PyThreadState*)_Py_atomic_load_relaxed(
- &_PyThreadState_Current);
+ tstate = _PyThreadState_UncheckedGet();
if (tstate != NULL && tstate->curexc_type != NULL) {
/* preserve the existing exception */
PyObject *err_type, *err_value, *err_tb;