@@ -499,56 +499,28 @@ sys_addaudithook_impl(PyObject *module, PyObject *hook)
499499 Py_RETURN_NONE ;
500500}
501501
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]*/
507511
508512static 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]*/
510515{
511516 PyThreadState * tstate = _PyThreadState_GET ();
512517 _Py_EnsureTstateNotNULL (tstate );
513518
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-
523519 if (!should_audit (tstate -> interp )) {
524520 Py_RETURN_NONE ;
525521 }
526522
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 );
552524 if (res < 0 ) {
553525 return NULL ;
554526 }
@@ -2564,7 +2536,7 @@ PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
25642536static PyMethodDef sys_methods [] = {
25652537 /* Might as well keep this in alphabetic order */
25662538 SYS_ADDAUDITHOOK_METHODDEF
2567- { "audit" , _PyCFunction_CAST ( sys_audit ), METH_FASTCALL , audit_doc },
2539+ SYS_AUDIT_METHODDEF
25682540 {"breakpointhook" , _PyCFunction_CAST (sys_breakpointhook ),
25692541 METH_FASTCALL | METH_KEYWORDS , breakpointhook_doc },
25702542 SYS__CLEAR_INTERNAL_CACHES_METHODDEF
0 commit comments