Skip to content

Commit 144f61c

Browse files
committed
clinic argument for socket.inet_aton
1 parent d92ddd3 commit 144f61c

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

Modules/clinic/socketmodule.c.h

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/socketmodule.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6457,14 +6457,17 @@ Convert a 32-bit integer from host to network byte order.");
64576457

64586458
/* socket.inet_aton() and socket.inet_ntoa() functions. */
64596459

6460-
PyDoc_STRVAR(inet_aton_doc,
6461-
"inet_aton(string) -> bytes giving packed 32-bit IP representation\n\
6462-
\n\
6463-
Convert an IP address in string format (123.45.67.89) to the 32-bit packed\n\
6464-
binary format used in low-level network functions.");
6460+
/*[clinic input]
6461+
_socket.socket.inet_aton
6462+
ip_addr: str
6463+
/
64656464
6466-
static PyObject*
6467-
socket_inet_aton(PyObject *self, PyObject *args)
6465+
Convert an IP address in string format (123.45.67.89) to the 32-bit packed binary format used in low-level network functions.
6466+
[clinic start generated code]*/
6467+
6468+
static PyObject *
6469+
_socket_socket_inet_aton_impl(PySocketSockObject *self, const char *ip_addr)
6470+
/*[clinic end generated code: output=5bfe11a255423d8c input=a120e20cb52b9488]*/
64686471
{
64696472
#ifdef HAVE_INET_ATON
64706473
struct in_addr buf;
@@ -6477,11 +6480,6 @@ socket_inet_aton(PyObject *self, PyObject *args)
64776480
/* Have to use inet_addr() instead */
64786481
unsigned int packed_addr;
64796482
#endif
6480-
const char *ip_addr;
6481-
6482-
if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr))
6483-
return NULL;
6484-
64856483

64866484
#ifdef HAVE_INET_ATON
64876485

@@ -7219,8 +7217,7 @@ static PyMethodDef socket_methods[] = {
72197217
_SOCKET_SOCKET_HTONS_METHODDEF
72207218
{"htonl", socket_htonl,
72217219
METH_O, htonl_doc},
7222-
{"inet_aton", socket_inet_aton,
7223-
METH_VARARGS, inet_aton_doc},
7220+
_SOCKET_SOCKET_INET_ATON_METHODDEF
72247221
#ifdef HAVE_INET_NTOA
72257222
{"inet_ntoa", socket_inet_ntoa,
72267223
METH_VARARGS, inet_ntoa_doc},

0 commit comments

Comments
 (0)