@@ -6360,15 +6360,18 @@ _socket_socket_ntohs_impl(PySocketSockObject *self, int x)
6360
6360
}
6361
6361
6362
6362
6363
+ /*[clinic input]
6364
+ _socket.socket.ntohl
6365
+ x: unsigned_long(bitwise=True)
6366
+ /
6367
+
6368
+ Convert a 32-bit integer from network to host byte order.
6369
+ [clinic start generated code]*/
6370
+
6363
6371
static PyObject *
6364
- socket_ntohl (PyObject * self , PyObject * arg )
6372
+ _socket_socket_ntohl_impl (PySocketSockObject * self , unsigned long x )
6373
+ /*[clinic end generated code: output=88e46cad3e45c65c input=02a9a0c0ad14a079]*/
6365
6374
{
6366
- unsigned long x ;
6367
-
6368
- if (PyLong_Check (arg )) {
6369
- x = PyLong_AsUnsignedLong (arg );
6370
- if (x == (unsigned long ) -1 && PyErr_Occurred ())
6371
- return NULL ;
6372
6375
#if SIZEOF_LONG > 4
6373
6376
{
6374
6377
unsigned long y ;
@@ -6380,19 +6383,9 @@ socket_ntohl(PyObject *self, PyObject *arg)
6380
6383
x = y ;
6381
6384
}
6382
6385
#endif
6383
- }
6384
- else
6385
- return PyErr_Format (PyExc_TypeError ,
6386
- "expected int, %s found" ,
6387
- Py_TYPE (arg )-> tp_name );
6388
6386
return PyLong_FromUnsignedLong (ntohl (x ));
6389
6387
}
6390
6388
6391
- PyDoc_STRVAR (ntohl_doc ,
6392
- "ntohl(integer) -> integer\n\
6393
- \n\
6394
- Convert a 32-bit integer from network to host byte order." );
6395
-
6396
6389
6397
6390
/*[clinic input]
6398
6391
_socket.socket.htons
@@ -7212,8 +7205,7 @@ static PyMethodDef socket_methods[] = {
7212
7205
METH_VARARGS , socketpair_doc },
7213
7206
#endif
7214
7207
_SOCKET_SOCKET_NTOHS_METHODDEF
7215
- {"ntohl" , socket_ntohl ,
7216
- METH_O , ntohl_doc },
7208
+ _SOCKET_SOCKET_NTOHL_METHODDEF
7217
7209
_SOCKET_SOCKET_HTONS_METHODDEF
7218
7210
{"htonl" , socket_htonl ,
7219
7211
METH_O , htonl_doc },
0 commit comments