summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-26 17:57:32 (GMT)
committerGitHub <noreply@github.com>2020-03-26 17:57:32 (GMT)
commit08faf0016e1ee590c78f64ddb244767c7801866a (patch)
tree17c3ad20544ec8725838cad831d88147f572a6a9 /Include
parente0b8101492f6c61dee831425b4d3dae39a953599 (diff)
downloadcpython-08faf0016e1ee590c78f64ddb244767c7801866a.zip
cpython-08faf0016e1ee590c78f64ddb244767c7801866a.tar.gz
cpython-08faf0016e1ee590c78f64ddb244767c7801866a.tar.bz2
bpo-38644: Add _PySys_Audit() which takes tstate (GH-19180)
Add _PySys_Audit() function to the internal C API: similar to PySys_Audit(), but requires a mandatory tstate parameter. Cleanup sys_audit_tstate() code: remove code path for NULL tstate, since the function exits at entry if tstate is NULL. Remove also code path for NULL tstate->interp: should_audit() now ensures that it is not NULL (even if tstate->interp cannot be NULL in practice). PySys_AddAuditHook() now checks if tstate is not NULL to decide if tstate can be used or not, and tstate is set to NULL if the runtime is not initialized yet. Use _PySys_Audit() in sysmodule.c.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/sysmodule.h5
-rw-r--r--Include/internal/pycore_sysmodule.h24
2 files changed, 28 insertions, 1 deletions
diff --git a/Include/cpython/sysmodule.h b/Include/cpython/sysmodule.h
index 72d8ffe..1802b5b 100644
--- a/Include/cpython/sysmodule.h
+++ b/Include/cpython/sysmodule.h
@@ -13,7 +13,10 @@ PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
-PyAPI_FUNC(int) PySys_Audit(const char*, const char *, ...);
+PyAPI_FUNC(int) PySys_Audit(
+ const char *event,
+ const char *argFormat,
+ ...);
PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
#ifdef __cplusplus
diff --git a/Include/internal/pycore_sysmodule.h b/Include/internal/pycore_sysmodule.h
new file mode 100644
index 0000000..738a774
--- /dev/null
+++ b/Include/internal/pycore_sysmodule.h
@@ -0,0 +1,24 @@
+#ifndef Py_INTERNAL_SYSMODULE_H
+#define Py_INTERNAL_SYSMODULE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+# error "this header requires Py_BUILD_CORE define"
+#endif
+
+PyAPI_FUNC(int) _PySys_Audit(
+ PyThreadState *tstate,
+ const char *event,
+ const char *argFormat,
+ ...);
+
+/* We want minimal exposure of this function, so use extern rather than
+ PyAPI_FUNC() to not export the symbol. */
+extern void _PySys_ClearAuditHooks(PyThreadState *tstate);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_SYSMODULE_H */