summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2019-05-23 15:45:22 (GMT)
committerGitHub <noreply@github.com>2019-05-23 15:45:22 (GMT)
commitb82e17e626f7b1cd98aada0b1ebb65cb9f8fb184 (patch)
tree5370a2a075707cb0b37ce135cad6ffe23da424c4 /Python/ceval.c
parente788057a9188ff37e232729815dfda2529079420 (diff)
downloadcpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.zip
cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.tar.gz
cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.tar.bz2
bpo-36842: Implement PEP 578 (GH-12613)
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 1bb4704..781b10d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4555,6 +4555,10 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
void
PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
{
+ if (PySys_Audit("sys.setprofile", NULL) < 0) {
+ return;
+ }
+
PyThreadState *tstate = _PyThreadState_GET();
PyObject *temp = tstate->c_profileobj;
Py_XINCREF(arg);
@@ -4572,6 +4576,10 @@ PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
void
PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
{
+ if (PySys_Audit("sys.settrace", NULL) < 0) {
+ return;
+ }
+
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
PyObject *temp = tstate->c_traceobj;
@@ -4608,6 +4616,11 @@ void
_PyEval_SetCoroutineWrapper(PyObject *wrapper)
{
PyThreadState *tstate = _PyThreadState_GET();
+
+ if (PySys_Audit("sys.set_coroutine_wrapper", NULL) < 0) {
+ return;
+ }
+
Py_XINCREF(wrapper);
Py_XSETREF(tstate->coroutine_wrapper, wrapper);
}
@@ -4623,6 +4636,11 @@ void
_PyEval_SetAsyncGenFirstiter(PyObject *firstiter)
{
PyThreadState *tstate = _PyThreadState_GET();
+
+ if (PySys_Audit("sys.set_asyncgen_hook_firstiter", NULL) < 0) {
+ return;
+ }
+
Py_XINCREF(firstiter);
Py_XSETREF(tstate->async_gen_firstiter, firstiter);
}
@@ -4638,6 +4656,11 @@ void
_PyEval_SetAsyncGenFinalizer(PyObject *finalizer)
{
PyThreadState *tstate = _PyThreadState_GET();
+
+ if (PySys_Audit("sys.set_asyncgen_hook_finalizer", NULL) < 0) {
+ return;
+ }
+
Py_XINCREF(finalizer);
Py_XSETREF(tstate->async_gen_finalizer, finalizer);
}