bpo-39947: Add _PyThreadState_GetDict() by vstinner · Pull Request #19160 · python/cpython
/* -------------------------------------------------------------------------- CAUTION
PyObject * _PyThreadState_GetDict(PyThreadState *tstate) { assert(tstate != NULL); if (tstate->dict == NULL) { tstate->dict = PyDict_New(); if (tstate->dict == NULL) { _PyErr_Clear(tstate); } } return tstate->dict; }
PyObject * PyThreadState_GetDict(void) { PyThreadState *tstate = _PyThreadState_GET(); if (tstate == NULL) if (tstate == NULL) { return NULL;
if (tstate->dict == NULL) { PyObject *d; tstate->dict = d = PyDict_New(); if (d == NULL) PyErr_Clear(); } return tstate->dict; return _PyThreadState_GetDict(tstate); }