@@ -6415,15 +6415,18 @@ _socket_socket_htons_impl(PySocketSockObject *self, int x)
6415
6415
}
6416
6416
6417
6417
6418
+ /*[clinic input]
6419
+ _socket.socket.htonl
6420
+ x: unsigned_long(bitwise=True)
6421
+ /
6422
+
6423
+ Convert a 32-bit integer from host to network byte order.
6424
+ [clinic start generated code]*/
6425
+
6418
6426
static PyObject *
6419
- socket_htonl (PyObject * self , PyObject * arg )
6427
+ _socket_socket_htonl_impl (PySocketSockObject * self , unsigned long x )
6428
+ /*[clinic end generated code: output=04a88551f090913e input=e356f217ac56bef5]*/
6420
6429
{
6421
- unsigned long x ;
6422
-
6423
- if (PyLong_Check (arg )) {
6424
- x = PyLong_AsUnsignedLong (arg );
6425
- if (x == (unsigned long ) -1 && PyErr_Occurred ())
6426
- return NULL ;
6427
6430
#if SIZEOF_LONG > 4
6428
6431
{
6429
6432
unsigned long y ;
@@ -6435,19 +6438,9 @@ socket_htonl(PyObject *self, PyObject *arg)
6435
6438
x = y ;
6436
6439
}
6437
6440
#endif
6438
- }
6439
- else
6440
- return PyErr_Format (PyExc_TypeError ,
6441
- "expected int, %s found" ,
6442
- Py_TYPE (arg )-> tp_name );
6443
- return PyLong_FromUnsignedLong (htonl ((unsigned long )x ));
6441
+ return PyLong_FromUnsignedLong (htonl (x ));
6
8000
444
6442
}
6445
6443
6446
- PyDoc_STRVAR (htonl_doc ,
6447
- "htonl(integer) -> integer\n\
6448
- \n\
6449
- Convert a 32-bit integer from host to network byte order." );
6450
-
6451
6444
/* socket.inet_aton() and socket.inet_ntoa() functions. */
6452
6445
6453
6446
/*[clinic input]
@@ -7207,8 +7200,7 @@ static PyMethodDef socket_methods[] = {
7207
7200
_SOCKET_SOCKET_NTOHS_METHODDEF
7208
7201
_SOCKET_SOCKET_NTOHL_METHODDEF
7209
7202
_SOCKET_SOCKET_HTONS_METHODDEF
7210
- {"htonl" , socket_htonl ,
7211
- METH_O , htonl_doc },
7203
+ _SOCKET_SOCKET_HTONL_METHODDEF
7212
7204
_SOCKET_SOCKET_INET_ATON_METHODDEF
7213
7205
#ifdef HAVE_INET_NTOA
7214
7206
_SOCKET_SOCKET_INET_NTOA_METHODDEF
0 commit comments