Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:func:`socket.if_nametoindex` and :func:`socket.if_indextoname` are now
available on platforms that provide them but not ``if_nameindex()``, such
as Android before API level 24.
10 changes: 5 additions & 5 deletions Modules/clinic/socketmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,14 @@ _PyLong_##NAME##_Converter(PyObject *obj, void *ptr) \
return 1; \
}

#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)
# ifdef MS_WINDOWS
UNSIGNED_INT_CONVERTER(NetIfindex, NET_IFINDEX)
# else
# define _PyLong_NetIfindex_Converter _PyLong_UnsignedInt_Converter
# define NET_IFINDEX unsigned int
# endif
#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)

/*[python input]
class NET_IFINDEX_converter(CConverter):
Expand Down Expand Up @@ -7403,6 +7403,9 @@ _socket_if_nameindex_impl(PyObject *module)
#endif
}

#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)

#if defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS)

/*[clinic input]
_socket.if_nametoindex
Expand Down Expand Up @@ -7432,6 +7435,9 @@ _socket_if_nametoindex_impl(PyObject *module, PyObject *oname)
return PyLong_FromUnsignedLong(index);
}

#endif // defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS)

#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)

/*[clinic input]
@permit_long_summary
Expand All @@ -7456,7 +7462,7 @@ _socket_if_indextoname_impl(PyObject *module, NET_IFINDEX index)
return PyUnicode_DecodeFSDefault(name);
}

#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)


#ifdef CMSG_LEN
Expand Down
13 changes: 12 additions & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5507,7 +5507,8 @@ AC_CHECK_FUNCS([ \
getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin getlogin_r \
getpeername getpgid getpid getppid getpriority _getpty \
getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \
getspnam gettid getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \
getspnam gettid getuid getwd grantpt if_indextoname if_nameindex \
if_nametoindex initgroups kill killpg lchown linkat \
lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \
mknod mknodat mktime mmap mremap nice openat opendir pathconf pause \
pidfd_open pidfd_getfd pidfd_send_signal pipe \
Expand Down
7 changes: 6 additions & 1 deletion pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,15 @@
/* Define to 1 if you have the <iconv.h> header file. */
#undef HAVE_ICONV_H

/* Define to 1 if you have the 'if_indextoname' function. */
#undef HAVE_IF_INDEXTONAME

/* Define to 1 if you have the 'if_nameindex' function. */
#undef HAVE_IF_NAMEINDEX

/* Define to 1 if you have the 'if_nametoindex' function. */
#undef HAVE_IF_NAMETOINDEX

/* Define if you have the 'inet_aton' function. */
#undef HAVE_INET_ATON

Expand Down Expand Up @@ -2279,4 +2285,3 @@
#endif

#endif /*Py_PYCONFIG_H*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we lose this line?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because I copied the diff from GitHub Actions and my editor removes trailing newlines... oops!

Loading