@@ -706,35 +706,43 @@ signal_siginterrupt_impl(PyObject *module, int signalnum, int flag)
706706#endif
707707
708708
709- static PyObject *
710- signal_set_wakeup_fd (PyObject * self , PyObject * args , PyObject * kwds )
709+ /*[clinic input]
710+ signal.set_wakeup_fd
711+
712+ fd as fdobj: object
713+ /
714+ *
715+ warn_on_full_buffer: bool = True
716+
717+ Sets the fd to be written to (with the signal number) when a signal comes in.
718+
719+ A library can use this to wakeup select or poll.
720+ The previous fd or -1 is returned.
721+
722+ The fd must be non-blocking.
723+ [clinic start generated code]*/
724+
725+ static PyObject *
726+ signal_set_wakeup_fd_impl (PyObject * module , PyObject * fdobj ,
727+ int warn_on_full_buffer )
728+ /*[clinic end generated code: output=2280d72dd2a54c4f input=5b545946a28b8339]*/
711729{
712730 struct _Py_stat_struct status ;
713- static char * kwlist [] = {
714- "" , "warn_on_full_buffer" , NULL ,
715- };
716- int warn_on_full_buffer = 1 ;
717731#ifdef MS_WINDOWS
718- PyObject * fdobj ;
719732 SOCKET_T sockfd , old_sockfd ;
720733 int res ;
721734 int res_size = sizeof res ;
722735 PyObject * mod ;
723736 int is_socket ;
724737
725- if (!PyArg_ParseTupleAndKeywords (args , kwds , "O|$p:set_wakeup_fd" , kwlist ,
726- & fdobj , & warn_on_full_buffer ))
727- return NULL ;
728-
729738 sockfd = PyLong_AsSocket_t (fdobj );
730739 if (sockfd == (SOCKET_T )(-1 ) && PyErr_Occurred ())
731740 return NULL ;
732741#else
733- int fd ;
734-
735- if (!PyArg_ParseTupleAndKeywords (args , kwds , "i|$p:set_wakeup_fd" , kwlist ,
736- & fd , & warn_on_full_buffer ))
742+ int fd = PyLong_AsInt (fdobj );
743+ if (fd == -1 && PyErr_Occurred ()) {
737744 return NULL ;
745+ }
738746#endif
739747
740748 PyThreadState * tstate = _PyThreadState_GET ();
@@ -820,15 +828,6 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds)
820828#endif
821829}
822830
823- PyDoc_STRVAR (set_wakeup_fd_doc ,
824- "set_wakeup_fd(fd, *, warn_on_full_buffer=True) -> fd\n\
825- \n\
826- Sets the fd to be written to (with the signal number) when a signal\n\
827- comes in. A library can use this to wakeup select or poll.\n\
828- The previous fd or -1 is returned.\n\
829- \n\
830- The fd must be non-blocking." );
831-
832831/* C API for the same, without all the error checking */
833832int
834833PySignal_SetWakeupFd (int fd )
@@ -1344,7 +1343,7 @@ static PyMethodDef signal_methods[] = {
13441343 SIGNAL_RAISE_SIGNAL_METHODDEF
13451344 SIGNAL_STRSIGNAL_METHODDEF
13461345 SIGNAL_GETSIGNAL_METHODDEF
1347- { "set_wakeup_fd" , _PyCFunction_CAST ( signal_set_wakeup_fd ), METH_VARARGS | METH_KEYWORDS , set_wakeup_fd_doc },
1346+ SIGNAL_SET_WAKEUP_FD_METHODDEF
13481347 SIGNAL_SIGINTERRUPT_METHODDEF
13491348 SIGNAL_PAUSE_METHODDEF
13501349 SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
0 commit comments