Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pypy3-exe/, dev-python/pypy3-exe/files/
Date: Sun, 04 Oct 2020 21:15:19
Message-Id: 1601846080.f0e786f0096b75d886fca041c479e936fb27e0b9.mgorny@gentoo
1 commit: f0e786f0096b75d886fca041c479e936fb27e0b9
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Oct 4 19:40:32 2020 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Oct 4 21:14:40 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0e786f0
7
8 dev-python/pypy3-exe: Backport sethostname() fix
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 .../files/pypy3-7.3.2-sethostname-bytes.patch | 61 ++++++++++++++++++++++
13 ...-exe-7.3.2.ebuild => pypy3-exe-7.3.2-r1.ebuild} | 4 ++
14 ....2_p37.ebuild => pypy3-exe-7.3.2_p37-r1.ebuild} | 4 ++
15 3 files changed, 69 insertions(+)
16
17 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
18 new file mode 100644
19 index 00000000000..68025600b1f
20 --- /dev/null
21 +++ b/dev-python/pypy3-exe/files/pypy3-7.3.2-sethostname-bytes.patch
22 @@ -0,0 +1,61 @@
23 +From 5ee2925459372a8af805e952f433acd75e426325 Mon Sep 17 00:00:00 2001
24 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
25 +Date: Sun, 4 Oct 2020 15:46:23 +0200
26 +Subject: [PATCH] Fix sethostname() failure when passed bytes
27 +
28 +My implementation of sethostname() was broken and failed when passed
29 +bytes on Python 3. Update the implementation to match CPython -- that
30 +is, use bytes if provided, or fsencode() when str is provided.
31 +
32 +--HG--
33 +branch : py3.6
34 +---
35 + pypy/module/_socket/interp_func.py | 8 +++++++-
36 + pypy/module/_socket/test/test_sock_app.py | 12 ++++++++++++
37 + 2 files changed, 19 insertions(+), 1 deletion(-)
38 +
39 +diff --git a/pypy/module/_socket/interp_func.py b/pypy/module/_socket/interp_func.py
40 +index bdc4f1293f..1727e51d51 100644
41 +--- a/pypy/module/_socket/interp_func.py
42 ++++ b/pypy/module/_socket/interp_func.py
43 +@@ -392,7 +392,13 @@ if hasattr(rsocket, 'sethostname'):
44 +
45 + Set the host name.
46 + """
47 +- hostname = space.text_w(w_hostname)
48 ++ if space.isinstance_w(w_hostname, space.w_bytes):
49 ++ hostname = space.bytes_w(w_hostname)
50 ++ elif space.isinstance_w(w_hostname, space.w_unicode):
51 ++ hostname = space.fsencode_w(w_hostname)
52 ++ else:
53 ++ raise oefmt(space.w_TypeError,
54 ++ "sethostname() argument 1 must be str or bytes")
55 + try:
56 + res = rsocket.sethostname(hostname)
57 + except SocketError as e:
58 +diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
59 +index fe3efec8e3..355fb8a2a9 100644
60 +--- a/pypy/module/_socket/test/test_sock_app.py
61 ++++ b/pypy/module/_socket/test/test_sock_app.py
62 +@@ -210,6 +210,18 @@ def test_getaddrinfo(space, w_socket):
63 + assert space.unwrap(w_l) == True
64 +
65 +
66 ++def test_sethostname(space, w_socket):
67 ++ space.raises_w(space.w_OSError, space.appexec,
68 ++ [w_socket],
69 ++ "(_socket): _socket.sethostname(_socket.gethostname())")
70 ++
71 ++
72 ++def test_sethostname_bytes(space, w_socket):
73 ++ space.raises_w(space.w_OSError, space.appexec,
74 ++ [w_socket],
75 ++ "(_socket): _socket.sethostname(_socket.gethostname().encode())")
76 ++
77 ++
78 + def test_unknown_addr_as_object(space, ):
79 + from pypy.module._socket.interp_socket import addr_as_object
80 + c_addr = lltype.malloc(rsocket._c.sockaddr, flavor='raw', track_allocation=False)
81 +--
82 +GitLab
83 +
84
85 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
86 similarity index 98%
87 rename from dev-python/pypy3-exe/pypy3-exe-7.3.2.ebuild
88 rename to dev-python/pypy3-exe/pypy3-exe-7.3.2-r1.ebuild
89 index a8648c1e6ea..73313264113 100644
90 --- a/dev-python/pypy3-exe/pypy3-exe-7.3.2.ebuild
91 +++ b/dev-python/pypy3-exe/pypy3-exe-7.3.2-r1.ebuild
92 @@ -35,6 +35,10 @@ BDEPEND="
93 )
94 )"
95
96 +PATCHES=(
97 + "${FILESDIR}"/pypy3-7.3.2-sethostname-bytes.patch
98 +)
99 +
100 check_env() {
101 if use low-memory; then
102 CHECKREQS_MEMORY="1750M"
103
104 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
105 similarity index 98%
106 rename from dev-python/pypy3-exe/pypy3-exe-7.3.2_p37.ebuild
107 rename to dev-python/pypy3-exe/pypy3-exe-7.3.2_p37-r1.ebuild
108 index 5992fb3e87e..592f395defc 100644
109 --- a/dev-python/pypy3-exe/pypy3-exe-7.3.2_p37.ebuild
110 +++ b/dev-python/pypy3-exe/pypy3-exe-7.3.2_p37-r1.ebuild
111 @@ -36,6 +36,10 @@ BDEPEND="
112 )
113 )"
114
115 +PATCHES=(
116 + "${FILESDIR}"/pypy3-7.3.2-sethostname-bytes.patch
117 +)
118 +
119 check_env() {
120 if use low-memory; then
121 CHECKREQS_MEMORY="1750M"