diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-27 14:11:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 14:11:45 (GMT) |
commit | 1c1e68cf3e3a2a19a0edca9a105273e11ddddc6e (patch) | |
tree | 5ca84d927ab6ffa09308943075d056e604f3667b /Python/ceval.c | |
parent | 33f15a16d40cb8010a8c758952cbf88d7912ee2d (diff) | |
download | cpython-1c1e68cf3e3a2a19a0edca9a105273e11ddddc6e.zip cpython-1c1e68cf3e3a2a19a0edca9a105273e11ddddc6e.tar.gz cpython-1c1e68cf3e3a2a19a0edca9a105273e11ddddc6e.tar.bz2 |
bpo-38644: Use _PySys_Audit(): pass tstate explicitly (GH-19183)
Add the dependency to tstate more explicit.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 2be02a1..d79a239 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -18,6 +18,7 @@ #include "pycore_pyerrors.h" #include "pycore_pylifecycle.h" #include "pycore_pystate.h" +#include "pycore_sysmodule.h" #include "pycore_tupleobject.h" #include "code.h" @@ -4693,9 +4694,10 @@ _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg) /* The caller must hold the GIL */ assert(PyGILState_Check()); - /* Call PySys_Audit() in the context of the current thread state, + /* Call _PySys_Audit() in the context of the current thread state, even if tstate is not the current thread state. */ - if (PySys_Audit("sys.setprofile", NULL) < 0) { + PyThreadState *current_tstate = _PyThreadState_GET(); + if (_PySys_Audit(current_tstate, "sys.setprofile", NULL) < 0) { return -1; } @@ -4721,7 +4723,7 @@ PyEval_SetProfile(Py_tracefunc func, PyObject *arg) { PyThreadState *tstate = _PyThreadState_GET(); if (_PyEval_SetProfile(tstate, func, arg) < 0) { - /* Log PySys_Audit() error */ + /* Log _PySys_Audit() error */ _PyErr_WriteUnraisableMsg("in PyEval_SetProfile", NULL); } } @@ -4733,9 +4735,10 @@ _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg) /* The caller must hold the GIL */ assert(PyGILState_Check()); - /* Call PySys_Audit() in the context of the current thread state, + /* Call _PySys_Audit() in the context of the current thread state, even if tstate is not the current thread state. */ - if (PySys_Audit("sys.settrace", NULL) < 0) { + PyThreadState *current_tstate = _PyThreadState_GET(); + if (_PySys_Audit(current_tstate, "sys.settrace", NULL) < 0) { return -1; } @@ -4765,7 +4768,7 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg) { PyThreadState *tstate = _PyThreadState_GET(); if (_PyEval_SetTrace(tstate, func, arg) < 0) { - /* Log PySys_Audit() error */ + /* Log _PySys_Audit() error */ _PyErr_WriteUnraisableMsg("in PyEval_SetTrace", NULL); } } @@ -4790,7 +4793,7 @@ _PyEval_SetAsyncGenFirstiter(PyObject *firstiter) { PyThreadState *tstate = _PyThreadState_GET(); - if (PySys_Audit("sys.set_asyncgen_hook_firstiter", NULL) < 0) { + if (_PySys_Audit(tstate, "sys.set_asyncgen_hook_firstiter", NULL) < 0) { return -1; } @@ -4811,7 +4814,7 @@ _PyEval_SetAsyncGenFinalizer(PyObject *finalizer) { PyThreadState *tstate = _PyThreadState_GET(); - if (PySys_Audit("sys.set_asyncgen_hook_finalizer", NULL) < 0) { + if (_PySys_Audit(tstate, "sys.set_asyncgen_hook_finalizer", NULL) < 0) { return -1; } |