summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-13 10:05:25 (GMT)
committerGitHub <noreply@github.com>2022-09-13 10:05:25 (GMT)
commit390123b412346eb4438665f068bb73226ac84e7c (patch)
tree3b423e21403114ffaf09af4c447f282ea15ecb70
parent14adf4667e401a6257fe71c595a9a5c7c1f84c67 (diff)
downloadcpython-390123b412346eb4438665f068bb73226ac84e7c.zip
cpython-390123b412346eb4438665f068bb73226ac84e7c.tar.gz
cpython-390123b412346eb4438665f068bb73226ac84e7c.tar.bz2
[3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748)
- ignore missing functions in ``socket.__repr__`` - bundle network files with assets
-rw-r--r--Lib/socket.py5
-rw-r--r--Misc/NEWS.d/next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst2
-rwxr-xr-xTools/wasm/wasm_assets.py3
3 files changed, 7 insertions, 3 deletions
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)