From 390123b412346eb4438665f068bb73226ac84e7c Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 13 Sep 2022 03:05:25 -0700 Subject: [3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748) - ignore missing functions in ``socket.__repr__`` - bundle network files with assets --- Lib/socket.py | 5 +++-- .../next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst | 2 ++ Tools/wasm/wasm_assets.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst diff --git a/Lib/socket.py b/Lib/socket.py index a196522..0717c69 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 0000000..3a35c47 --- /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 40acea2..34a9bb5 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) -- cgit v0.12