summaryrefslogtreecommitdiffstats
path: root/Programs/_testembed.c
diff options
context:
space:
mode:
authorKonge <zkonge@outlook.com>2020-07-03 21:06:46 (GMT)
committerGitHub <noreply@github.com>2020-07-03 21:06:46 (GMT)
commitdaa0fe03a517d335d48e65ace8e5da636e265a8f (patch)
treed6504f9bc7ae8a6c8d14c0da18e6e46c138231fb /Programs/_testembed.c
parentd160e0f8e283d0a8737644588b38e8c6a07c134f (diff)
downloadcpython-daa0fe03a517d335d48e65ace8e5da636e265a8f.zip
cpython-daa0fe03a517d335d48e65ace8e5da636e265a8f.tar.gz
cpython-daa0fe03a517d335d48e65ace8e5da636e265a8f.tar.bz2
bpo-41162: Clear audit hooks later during finalization (GH-21222)
Diffstat (limited to 'Programs/_testembed.c')
-rw-r--r--Programs/_testembed.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index b60d70b..5aad16a 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -1112,8 +1112,11 @@ static int test_open_code_hook(void)
return result;
}
+static int _audit_hook_clear_count = 0;
+
static int _audit_hook(const char *event, PyObject *args, void *userdata)
{
+ assert(args && PyTuple_CheckExact(args));
if (strcmp(event, "_testembed.raise") == 0) {
PyErr_SetString(PyExc_RuntimeError, "Intentional error");
return -1;
@@ -1122,6 +1125,8 @@ static int _audit_hook(const char *event, PyObject *args, void *userdata)
return -1;
}
return 0;
+ } else if (strcmp(event, "cpython._PySys_ClearAuditHooks") == 0) {
+ _audit_hook_clear_count += 1;
}
return 0;
}
@@ -1167,6 +1172,9 @@ static int test_audit(void)
{
int result = _test_audit(42);
Py_Finalize();
+ if (_audit_hook_clear_count != 1) {
+ return 0x1000 | _audit_hook_clear_count;
+ }
return result;
}