mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
bpo-36842: Implement PEP 578 (GH-12613)
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
This commit is contained in:
parent
e788057a91
commit
b82e17e626
70 changed files with 3565 additions and 1816 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue