Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b24d60

Browse filesBrowse files
authored
gh-95174: WASI: skip missing sockets functions (GH-95179)
1 parent daa64d6 commit 8b24d60
Copy full SHA for 8b24d60

11 files changed

+864-27Lines changed: 864 additions & 27 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_socket.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_socket.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,19 @@ def testWindowsSpecificConstants(self):
965965
socket.IPPROTO_L2TP
966966
socket.IPPROTO_SCTP
967967

968+
@unittest.skipIf(support.is_wasi, "WASI is missing these methods")
969+
def test_socket_methods(self):
970+
# socket methods that depend on a configure HAVE_ check. They should
971+
# be present on all platforms except WASI.
972+
names = [
973+
"_accept", "bind", "connect", "connect_ex", "getpeername",
974+
"getsockname", "listen", "recvfrom", "recvfrom_into", "sendto",
975+
"setsockopt", "shutdown"
976+
]
977+
for name in names:
978+
if not hasattr(socket.socket, name):
979+
self.fail(f"socket method {name} is missing")
980+
968981
@unittest.skipUnless(sys.platform == 'darwin', 'macOS specific test')
969982
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this test')
970983
def test3542SocketOptions(self):
Collapse file
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Python now skips missing :mod:`socket` functions and methods on WASI. WASI can only create sockets from existing fd / accept and has no netdb.
Collapse file

‎Modules/addrinfo.h‎

Copy file name to clipboardExpand all lines: Modules/addrinfo.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ struct sockaddr_storage {
162162
#ifdef __cplusplus
163163
extern "C" {
164164
#endif
165+
#ifdef ENABLE_IPV6
165166
extern void freehostent(struct hostent *);
167+
#endif
166168
#ifdef __cplusplus
167169
}
168170
#endif
Collapse file

‎Modules/getaddrinfo.c‎

Copy file name to clipboardExpand all lines: Modules/getaddrinfo.c
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
# define FAITH
6262
#endif
6363

64+
#ifdef HAVE_NETDB_H
65+
#define HAVE_GETADDRINFO 1
66+
6467
#define SUCCESS 0
6568
#define GAI_ANY 0
6669
#define YES 1
@@ -636,3 +639,5 @@ get_addr(hostname, af, res, pai, port0)
636639
*res = NULL;
637640
return error;
638641
}
642+
643+
#endif // HAVE_NETDB_H
Collapse file

‎Modules/getnameinfo.c‎

Copy file name to clipboardExpand all lines: Modules/getnameinfo.c
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
#include "addrinfo.h"
4949
#endif
5050

51+
#ifdef HAVE_NETDB_H
52+
#define HAVE_GETNAMEINFO 1
53+
5154
#define SUCCESS 0
5255
#define YES 1
5356
#define NO 0
@@ -211,3 +214,4 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
211214
}
212215
return SUCCESS;
213216
}
217+
#endif // HAVE_NETDB_H

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.