gh-96320: WASI socket fixes (#96388)

* gh-96320: WASI socket fixes

- ignore missing functions in ``socket.__repr__``
- bundle network files with assets

* blurb
This commit is contained in:
Christian Heimes 2022-08-30 06:36:11 +02:00 committed by GitHub
parent 6d403e264a
commit d0b3d235db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -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

View file

@ -0,0 +1,2 @@
Work around missing socket functions in :class:`~socket.socket`'s
``__repr__``.

View file

@ -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)