Skip to content

Commit 41bd31d

Browse files
committed
gh-96320: WASI socket fixes
- ignore missing functions in ``socket.__repr__`` - bundle network files with assets
1 parent af368a7 commit 41bd31d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/socket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,18 @@ def __repr__(self):
255255
self.type,
256256
self.proto)
257257
if not closed:
258+
# getsockname and getpeername may not be available on WASI.
258259
try:
259260
laddr = self.getsockname()
260261
if laddr:
261262
s += ", laddr=%s" % str(laddr)
262-
except error:
263+
except (error, AttributeError):
263264
pass
264265
try:
265266
raddr = self.getpeername()
266267
if raddr:
267268
s += ", raddr=%s" % str(raddr)
268-
except error:
269+
except (error, AttributeError):
269270
pass
270271
s += '>'
271272
return s

Tools/wasm/wasm_assets.py

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

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

0 commit comments

Comments
 (0)