8000 PySys_AuditTuple() args must be a tuple · python/cpython@8f6f566 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f6f566

Browse files
committed
PySys_AuditTuple() args must be a tuple
1 parent 5223fed commit 8f6f566

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Doc/c-api/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ accessible to C code. They all work with the current interpreter thread's
316316
317317
.. c:function:: int PySys_AuditTuple(const char *event, PyObject *args)
318318
319-
Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object. To
320-
pass no arguments, *args* can be *NULL*.
319+
Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object.
320+
*args* must be a :class:`tuple`. To pass no arguments, *args* can be *NULL*.
321321
322322
.. versionadded:: 3.13
323323

Programs/_testembed.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,9 @@ static int test_audit_tuple(void)
13451345
if (int_arg == NULL) {
13461346
goto error;
13471347
}
1348-
assert(PySys_AuditTuple("_testembed.set", int_arg) == 0);
1349-
assert(!PyErr_Occurred());
1350-
assert(sawSet == 555);
1348+
assert(PySys_AuditTuple("_testembed.set", int_arg) == -1);
1349+
assert(PyErr_ExceptionMatches(PyExc_TypeError));
1350+
PyErr_Clear();
13511351
Py_DECREF(int_arg);
13521352

13531353
// NULL is accepted and means "no arguments"

Python/sysmodule.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ int
354354
PySys_AuditTuple(const char *event, PyObject *args)
355355
{
356356
if (args) {
357+
if (!PyTuple_Check(args)) {
358+
PyErr_Format(PyExc_TypeError, "args must be tuple, got %s",
359+
Py_TYPE(args)->tp_name);
360+
return -1;
361+
}
362+
357363
return PySys_Audit(event, "O", args);
358364
}
359365
else {

0 commit comments

Comments
 (0)
0