mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
/* An extension mechanism to store arbitrary additional per-thread state.
PyThreadState_GetDict() returns a dictionary that can be used to hold such state; the caller should pick a unique key and store its state there. If PyThreadState_GetDict() returns NULL, an exception has been raised (most likely MemoryError) and the caller should pass on the exception. */ PyObject * PyThreadState_GetDict()
This commit is contained in:
parent
c45cf02938
commit
ede0439cd8
1 changed files with 21 additions and 0 deletions
|
@ -126,6 +126,8 @@ PyThreadState_New(interp)
|
||||||
tstate->ticker = 0;
|
tstate->ticker = 0;
|
||||||
tstate->tracing = 0;
|
tstate->tracing = 0;
|
||||||
|
|
||||||
|
tstate->dict = NULL;
|
||||||
|
|
||||||
tstate->curexc_type = NULL;
|
tstate->curexc_type = NULL;
|
||||||
tstate->curexc_value = NULL;
|
tstate->curexc_value = NULL;
|
||||||
tstate->curexc_traceback = NULL;
|
tstate->curexc_traceback = NULL;
|
||||||
|
@ -155,6 +157,8 @@ PyThreadState_Clear(tstate)
|
||||||
|
|
||||||
ZAP(tstate->frame);
|
ZAP(tstate->frame);
|
||||||
|
|
||||||
|
ZAP(tstate->dict);
|
||||||
|
|
||||||
ZAP(tstate->curexc_type);
|
ZAP(tstate->curexc_type);
|
||||||
ZAP(tstate->curexc_value);
|
ZAP(tstate->curexc_value);
|
||||||
ZAP(tstate->curexc_traceback);
|
ZAP(tstate->curexc_traceback);
|
||||||
|
@ -213,3 +217,20 @@ PyThreadState_Swap(new)
|
||||||
|
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* An extension mechanism to store arbitrary additional per-thread state.
|
||||||
|
PyThreadState_GetDict() returns a dictionary that can be used to hold such
|
||||||
|
state; the caller should pick a unique key and store its state there. If
|
||||||
|
PyThreadState_GetDict() returns NULL, an exception has been raised (most
|
||||||
|
likely MemoryError) and the caller should pass on the exception. */
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
PyThreadState_GetDict()
|
||||||
|
{
|
||||||
|
if (current_tstate == NULL)
|
||||||
|
Py_FatalError("PyThreadState_GetDict: no current thread");
|
||||||
|
|
||||||
|
if (current_tstate->dict == NULL)
|
||||||
|
current_tstate->dict = PyDict_New();
|
||||||
|
return current_tstate->dict;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue