8000 [3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748) · python/cpython@390123b · GitHub
[go: up one dir, main page]

Skip to content

Commit 390123b

Browse files
[3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748)
- ignore missing functions in ``socket.__repr__`` - bundle network files with assets
1 parent 14adf46 commit 390123b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Lib/socket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,18 @@ def __repr__(self):
254254
self.type,
255255
self.proto)
256256
if not closed:
257+
# getsockname and getpeername may not be available on WASI.
257258
try:
258259
laddr = self.getsockname()
259260
if laddr:
260261
s += ", laddr=%s" % str(laddr)
261-
except error:
262+
except (error, AttributeError):
262263
pass
263264
try:
264265
raddr = self.getpeername()
265266
if raddr:
266267
s += ", raddr=%s" % str(raddr)
267-
except error:
268+
except (error, AttributeError):
268269
pass
269270
s += '>'
270271
return s
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Work around missing socket functions in :class:`~socket.socket`'s
2+
``__repr__``.

Tools/wasm/wasm_assets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def main():
229229

230230
extmods = detect_extension_modules(args)
231231
omit_files = list(OMIT_FILES)
232-
omit_files.extend(OMIT_NETWORKING_FILES)
232+
if sysconfig.get_platform().startswith("emscripten"):
233+
omit_files.extend(OMIT_NETWORKING_FILES)
233234
for modname, modfiles in OMIT_MODULE_FILES.items():
234235
if not extmods.get(modname):
235236
omit_files.extend(modfiles)

0 commit comments

Comments
 (0)
0