Skip to content

Commit

Permalink
gh-96320: WASI socket fixes
Browse files Browse the repository at this point in the history
- ignore missing functions in ``socket.__repr__``
- bundle network files with assets
  • Loading branch information
tiran committed Aug 29, 2022
1 parent af368a7 commit 41bd31d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,18 @@ def __repr__(self):
self.type,
self.proto)
if not closed:
# getsockname and getpeername may not be available on WASI.
try:
laddr = self.getsockname()
if laddr:
s += ", laddr=%s" % str(laddr)
except error:
except (error, AttributeError):
pass
try:
raddr = self.getpeername()
if raddr:
s += ", raddr=%s" % str(raddr)
except error:
except (error, AttributeError):
pass
s += '>'
return s
Expand Down
3 changes: 2 additions & 1 deletion Tools/wasm/wasm_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def main():

extmods = detect_extension_modules(args)
omit_files = list(OMIT_FILES)
omit_files.extend(OMIT_NETWORKING_FILES)
if sysconfig.get_platform().startswith("emscripten"):
omit_files.extend(OMIT_NETWORKING_FILES)
for modname, modfiles in OMIT_MODULE_FILES.items():
if not extmods.get(modname):
omit_files.extend(modfiles)
Expand Down

0 comments on commit 41bd31d

Please sign in to comment.