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

tiran webhook-mailer at python.org
Tue Sep 13 06:05:31 EDT 2022


https://github.com/python/cpython/commit/390123b412346eb4438665f068bb73226ac84e7c
commit: 390123b412346eb4438665f068bb73226ac84e7c
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: tiran <christian at python.org>
date: 2022年09月13日T12:05:25+02:00
summary:
[3.11] gh-96320: WASI socket fixes (GH-96388) (GH-#96748)
- ignore missing functions in ``socket.__repr__``
- bundle network files with assets
files:
A Misc/NEWS.d/next/Library/2022-08-29-16-54-36.gh-issue-96388.dCpJcu.rst
M Lib/socket.py
M Tools/wasm/wasm_assets.py
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 @@ 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
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)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /