summaryrefslogtreecommitdiff
path: root/Programs
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2020-07-03 22:58:29 +0100
committerGitHub <noreply@github.com>2020-07-03 22:58:29 +0100
commite1d4fdc53347617bea1aff0d7112471453f65003 (patch)
tree16f76a529a56aaf34b47a070341641ea0ac16715 /Programs
parent1c776541a8805576c0a4363ca28c1d29423f02f6 (diff)
downloadcpython-git-e1d4fdc53347617bea1aff0d7112471453f65003.tar.gz
bpo-41162: Clear audit hooks later during finalization (GH-21222)
Co-authored-by: Konge <zkonge@outlook.com>
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_testembed.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index d89f6be657..3bf0c37a47 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -1116,8 +1116,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;
@@ -1126,6 +1129,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;
}
@@ -1171,6 +1176,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;
}