diff options
Diffstat (limited to 'Programs/_testembed.c')
-rw-r--r-- | Programs/_testembed.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index b98a38a..460d70c 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -1106,8 +1106,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; @@ -1116,6 +1119,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; } @@ -1161,6 +1166,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; } |