@@ -499,56 +499,28 @@ sys_addaudithook_impl(PyObject *module, PyObject *hook)
499
499
Py_RETURN_NONE ;
500
500
}
501
501
502
- PyDoc_STRVAR (audit_doc ,
503
- "audit($module, event, /, *args)\n\
504
- --\n\
505
- \n\
506
- Passes the event to any audit hooks that are attached." );
502
+ /*[clinic input]
503
+ sys.audit
504
+
505
+ event: str
506
+ /
507
+ *args: tuple
508
+
509
+ Passes the event to any audit hooks that are attached.
510
+ [clinic start generated code]*/
507
511
508
512
static PyObject *
509
- sys_audit (PyObject * self , PyObject * const * args , Py_ssize_t argc )
513
+ sys_audit_impl (PyObject * module , const char * event , PyObject * args )
514
+ /*[clinic end generated code: output=1d0fc82da768f49d input=ec3b688527945109]*/
510
515
{
511
516
PyThreadState * tstate = _PyThreadState_GET ();
512
517
_Py_EnsureTstateNotNULL (tstate );
513
518
514
- if (argc == 0 ) {
515
- _PyErr_SetString (tstate , PyExc_TypeError ,
516
- "audit() missing 1 required positional argument: "
517
- "'event'" );
518
- return NULL ;
519
- }
520
-
521
- assert (args [0 ] != NULL );
522
-
523
519
if (!should_audit (tstate -> interp )) {
524
520
Py_RETURN_NONE ;
525
521
}
526
522
527
- PyObject * auditEvent = args [0 ];
528
- if (!auditEvent ) {
529
- _PyErr_SetString (tstate , PyExc_TypeError ,
530
- "expected str for argument 'event'" );
531
- return NULL ;
532
- }
533
- if (!PyUnicode_Check (auditEvent )) {
534
- _PyErr_Format (tstate , PyExc_TypeError ,
535
- "expected str for argument 'event', not %.200s" ,
536
- Py_TYPE (auditEvent )-> tp_name );
537
- return NULL ;
538
- }
539
- const char * event = PyUnicode_AsUTF8 (auditEvent );
540
- if (!event ) {
541
- return NULL ;
542
- }
543
-
544
- PyObject * auditArgs = _PyTuple_FromArray (args + 1 , argc - 1 );
545
- if (!auditArgs ) {
546
- return NULL ;
547
- }
548
-
549
- int res = _PySys_Audit (tstate , event , "O" , auditArgs );
550
- Py_DECREF (auditArgs );
551
-
523
+ int res = _PySys_Audit (tstate , event , "O" , args );
552
524
if (res < 0 ) {
553
525
return NULL ;
554
526
}
@@ -2564,7 +2536,7 @@ PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
2564
2536
static PyMethodDef sys_methods [] = {
2565
2537
/* Might as well keep this in alphabetic order */
2566
2538
SYS_ADDAUDITHOOK_METHODDEF
2567
- { "audit" , _PyCFunction_CAST ( sys_audit ), METH_FASTCALL , audit_doc },
2539
+ SYS_AUDIT_METHODDEF
2568
2540
{"breakpointhook" , _PyCFunction_CAST (sys_breakpointhook ),
2569
2541
METH_FASTCALL | METH_KEYWORDS , breakpointhook_doc },
2570
2542
SYS__CLEAR_INTERNAL_CACHES_METHODDEF
0 commit comments