[3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748)

- ignore missing functions in ``socket.__repr__``
- bundle network files with assets
This commit is contained in:
Miss Islington (bot) 2022-09-13 03:05:25 -07:00 committed by GitHub
parent 14adf4667e
commit 390123b412
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -254,17 +254,18 @@ class socket(_socket.socket):
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

@ -229,7 +229,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)