@@ -328,6 +328,12 @@ static FlagRuntimeInfo win_runtime_flags[] = {
328
328
{14393 , "TCP_FASTOPEN" }
329
329
};
330
330
331
+ /*[clinic input]
332
+ module _socket
333
+ class _socket.socket "PySocketSockObject *" "&sock_type"
334
+ [clinic start generated code]*/
335
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=7a8313d9b7f51988]*/
336
+
331
337
static int
332
338
remove_unusable_flags (PyObject * m )
333
339
{
@@ -511,6 +517,8 @@ remove_unusable_flags(PyObject *m)
511
517
#define INADDR_NONE (-1)
512
518
#endif
513
519
520
+ #include "clinic/socketmodule.c.h"
521
+
514
522
/* XXX There's a problem here: *static* functions are not supposed to have
515
523
a Py prefix (or use CapitalizedWords). Later... */
516
524
@@ -1708,7 +1716,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
1708
1716
}
1709
1717
addr -> sun_family = s -> sock_family ;
1710
1718
memcpy (addr -> sun_path , path .buf , path .len );
1711
-
1719
+
1712
1720
retval = 1 ;
1713
1721
unix_out :
1714
1722
PyBuffer_Release (& path );
@@ -5103,14 +5111,23 @@ static int sock_cloexec_works = -1;
5103
5111
#endif
5104
5112
5105
5113
/*ARGSUSED*/
5114
+
5115
+ /*[clinic input]
5116
+ _socket.socket.__init__ as sock_initobj
5117
+ family: int = -1
5118
+ type: int = -1
5119
+ proto: int = -1
5120
+ fileno as fdobj: object = NULL
5121
+ [clinic start generated code]*/
5122
+
5106
5123
static int
5107
- sock_initobj (PyObject * self , PyObject * args , PyObject * kwds )
5124
+ sock_initobj_impl (PySocketSockObject * self , int family , int type , int proto ,
5125
+ PyObject * fdobj )
5126
+ /*[clinic end generated code: output=d114d026b9a9a810 input=04cfc32953f5cc25]*/
5108
5127
{
5109
- PySocketSockObject * s = (PySocketSockObject * )self ;
5110
- PyObject * fdobj = NULL ;
5128
+
5111
5129
SOCKET_T fd = INVALID_SOCKET ;
5112
- int family = -1 , type = -1 , proto = -1 ;
5113
- static char * keywords [] = {"family" , "type" , "proto" , "fileno" , 0 };
5130
+
5114
5131
#ifndef MS_WINDOWS
5115
5132
#ifdef SOCK_CLOEXEC
5116
5133
int * atomic_flag_works = & sock_cloexec_works ;
@@ -5119,18 +5136,13 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
5119
5136
#endif
5120
5137
#endif
5121
5138
5122
- if (!PyArg_ParseTupleAndKeywords (args , kwds ,
5123
- "|iiiO:socket" , keywords ,
5124
- & family , & type , & proto , & fdobj ))
5125
- return -1 ;
5126
-
5127
5139
#ifdef MS_WINDOWS
5128
5140
/* In this case, we don't use the family, type and proto args */
5129
5141
if (fdobj == NULL || fdobj == Py_None )
5130
5142
#endif
5131
5143
{
5132
5144
if (PySys_Audit ("socket.__new__" , "Oiii" ,
5133
- s , family , type , proto ) < 0 ) {
5145
+ self , family , type , proto ) < 0 ) {
5134
5146
return -1 ;
5135
5147
}
5136
5148
}
@@ -5148,7 +5160,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
5148
5160
}
5149
5161
memcpy (& info , PyBytes_AS_STRING (fdobj ), sizeof (info ));
5150
5162
5151
- if (PySys_Audit ("socket.__new__" , "Oiii" , s ,
5163
+ if (PySys_Audit ("socket.__new__" , "Oiii" , self ,
5152
5164
info .iAddressFamily , info .iSocketType ,
5153
5165
info .iProtocol ) < 0 ) {
5154
5166
return -1 ;
@@ -5318,7 +5330,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
5318
5330
}
5319
5331
#endif
5320
5332
}
5321
- if (init_sockobject (s , fd , family , type , proto ) == -1 ) {
5333
+ if (init_sockobject (self , fd , family , type , proto ) == -1 ) {
5322
5334
SOCKETCLOSE (fd );
5323
5335
return -1 ;
5324
5336
}
0 commit comments