From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:05:25 +0000 (-0700) Subject: [3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748) X-Git-Tag: v3.11.1~493 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=390123b412346eb4438665f068bb73226ac84e7c;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748) - ignore missing functions in ``socket.__repr__`` - bundle network files with assets --- diff --git a/Lib/socket.py b/Lib/socket.py index a19652247a52..0717c696b12e 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -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 diff --git a/Misc/NEWS.d/next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst b/Misc/NEWS.d/next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst new file mode 100644 index 000000000000..3a35c4734871 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst @@ -0,0 +1,2 @@ +Work around missing socket functions in :class:`~socket.socket`'s +``__repr__``. diff --git a/Tools/wasm/wasm_assets.py b/Tools/wasm/wasm_assets.py index 40acea2efaef..34a9bb5640a3 100755 --- a/Tools/wasm/wasm_assets.py +++ b/Tools/wasm/wasm_assets.py @@ -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)