summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-10-04 21:40:32 +0200
committerMichał Górny <mgorny@gentoo.org>2020-10-04 23:14:40 +0200
commitf0e786f0096b75d886fca041c479e936fb27e0b9 (patch)
tree69ce0da777762dc36c033028c1a5849b48fc2ce5 /dev-python/pypy3-exe
parentmedia-gfx/imagemagick: drop old (diff)
downloadgentoo-f0e786f0096b75d886fca041c479e936fb27e0b9.tar.gz
gentoo-f0e786f0096b75d886fca041c479e936fb27e0b9.tar.bz2
gentoo-f0e786f0096b75d886fca041c479e936fb27e0b9.zip
dev-python/pypy3-exe: Backport sethostname() fix
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/pypy3-exe')
-rw-r--r--dev-python/pypy3-exe/files/pypy3-7.3.2-sethostname-bytes.patch61
-rw-r--r--dev-python/pypy3-exe/pypy3-exe-7.3.2-r1.ebuild (renamed from dev-python/pypy3-exe/pypy3-exe-7.3.2.ebuild)4
-rw-r--r--dev-python/pypy3-exe/pypy3-exe-7.3.2_p37-r1.ebuild (renamed from dev-python/pypy3-exe/pypy3-exe-7.3.2_p37.ebuild)4
3 files changed, 69 insertions, 0 deletions
diff --git a/dev-python/pypy3-exe/files/pypy3-7.3.2-sethostname-bytes.patch b/dev-python/pypy3-exe/files/pypy3-7.3.2-sethostname-bytes.patch
new file mode 100644
index 000000000000..68025600b1f5
--- /dev/null
+++ b/dev-python/pypy3-exe/files/pypy3-7.3.2-sethostname-bytes.patch
@@ -0,0 +1,61 @@
+From 5ee2925459372a8af805e952f433acd75e426325 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sun, 4 Oct 2020 15:46:23 +0200
+Subject: [PATCH] Fix sethostname() failure when passed bytes
+
+My implementation of sethostname() was broken and failed when passed
+bytes on Python 3. Update the implementation to match CPython -- that
+is, use bytes if provided, or fsencode() when str is provided.
+
+--HG--
+branch : py3.6
+---
+ pypy/module/_socket/interp_func.py | 8 +++++++-
+ pypy/module/_socket/test/test_sock_app.py | 12 ++++++++++++
+ 2 files changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/pypy/module/_socket/interp_func.py b/pypy/module/_socket/interp_func.py
+index bdc4f1293f..1727e51d51 100644
+--- a/pypy/module/_socket/interp_func.py
++++ b/pypy/module/_socket/interp_func.py
+@@ -392,7 +392,13 @@ if hasattr(rsocket, 'sethostname'):
+
+ Set the host name.
+ """
+- hostname = space.text_w(w_hostname)
++ if space.isinstance_w(w_hostname, space.w_bytes):
++ hostname = space.bytes_w(w_hostname)
++ elif space.isinstance_w(w_hostname, space.w_unicode):
++ hostname = space.fsencode_w(w_hostname)
++ else:
++ raise oefmt(space.w_TypeError,
++ "sethostname() argument 1 must be str or bytes")
+ try:
+ res = rsocket.sethostname(hostname)
+ except SocketError as e:
+diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
+index fe3efec8e3..355fb8a2a9 100644
+--- a/pypy/module/_socket/test/test_sock_app.py
++++ b/pypy/module/_socket/test/test_sock_app.py
+@@ -210,6 +210,18 @@ def test_getaddrinfo(space, w_socket):
+ assert space.unwrap(w_l) == True
+
+
++def test_sethostname(space, w_socket):
++ space.raises_w(space.w_OSError, space.appexec,
++ [w_socket],
++ "(_socket): _socket.sethostname(_socket.gethostname())")
++
++
++def test_sethostname_bytes(space, w_socket):
++ space.raises_w(space.w_OSError, space.appexec,
++ [w_socket],
++ "(_socket): _socket.sethostname(_socket.gethostname().encode())")
++
++
+ def test_unknown_addr_as_object(space, ):
+ from pypy.module._socket.interp_socket import addr_as_object
+ c_addr = lltype.malloc(rsocket._c.sockaddr, flavor='raw', track_allocation=False)
+--
+GitLab
+
diff --git a/dev-python/pypy3-exe/pypy3-exe-7.3.2.ebuild b/dev-python/pypy3-exe/pypy3-exe-7.3.2-r1.ebuild
index a8648c1e6ea9..73313264113e 100644
--- a/dev-python/pypy3-exe/pypy3-exe-7.3.2.ebuild
+++ b/dev-python/pypy3-exe/pypy3-exe-7.3.2-r1.ebuild
@@ -35,6 +35,10 @@ BDEPEND="
)
)"
+PATCHES=(
+ "${FILESDIR}"/pypy3-7.3.2-sethostname-bytes.patch
+)
+
check_env() {
if use low-memory; then
CHECKREQS_MEMORY="1750M"
diff --git a/dev-python/pypy3-exe/pypy3-exe-7.3.2_p37.ebuild b/dev-python/pypy3-exe/pypy3-exe-7.3.2_p37-r1.ebuild
index 5992fb3e87ef..592f395defcf 100644
--- a/dev-python/pypy3-exe/pypy3-exe-7.3.2_p37.ebuild
+++ b/dev-python/pypy3-exe/pypy3-exe-7.3.2_p37-r1.ebuild
@@ -36,6 +36,10 @@ BDEPEND="
)
)"
+PATCHES=(
+ "${FILESDIR}"/pypy3-7.3.2-sethostname-bytes.patch
+)
+
check_env() {
if use low-memory; then
CHECKREQS_MEMORY="1750M"