bpo-36842: Implement PEP 578 (GH-12613)

Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
This commit is contained in:
Steve Dower 2019-05-23 08:45:22 -07:00 committed by GitHub
parent e788057a91
commit b82e17e626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 3565 additions and 1816 deletions

View file

@ -9,8 +9,10 @@ extern "C" {
#endif
#include "cpython/coreconfig.h"
#include "fileobject.h"
#include "pystate.h"
#include "pythread.h"
#include "sysmodule.h"
#include "pycore_gil.h" /* _gil_runtime_state */
#include "pycore_pathconfig.h"
@ -131,6 +133,8 @@ struct _is {
uint64_t tstate_next_unique_id;
struct _warnings_runtime_state warnings;
PyObject *audit_hooks;
};
PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(PY_INT64_T);
@ -154,6 +158,13 @@ struct _xidregitem {
struct _xidregitem *next;
};
/* runtime audit hook state */
typedef struct _Py_AuditHookEntry {
struct _Py_AuditHookEntry *next;
Py_AuditHookFunction hookCFunction;
void *userData;
} _Py_AuditHookEntry;
/* GIL state */
@ -224,6 +235,11 @@ typedef struct pyruntimestate {
struct _gilstate_runtime_state gilstate;
_PyPreConfig preconfig;
Py_OpenCodeHookFunction open_code_hook;
void *open_code_userdata;
_Py_AuditHookEntry *audit_hook_head;
// XXX Consolidate globals found via the check-c-globals script.
} _PyRuntimeState;