public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pypy3-exe/, dev-python/pypy3-exe/files/
Date: Sun,  4 Oct 2020 21:15:15 +0000 (UTC)	[thread overview]
Message-ID: <1601846080.f0e786f0096b75d886fca041c479e936fb27e0b9.mgorny@gentoo> (raw)

commit:     f0e786f0096b75d886fca041c479e936fb27e0b9
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 19:40:32 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 21:14:40 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0e786f0

dev-python/pypy3-exe: Backport sethostname() fix

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../files/pypy3-7.3.2-sethostname-bytes.patch      | 61 ++++++++++++++++++++++
 ...-exe-7.3.2.ebuild => pypy3-exe-7.3.2-r1.ebuild} |  4 ++
 ....2_p37.ebuild => pypy3-exe-7.3.2_p37-r1.ebuild} |  4 ++
 3 files changed, 69 insertions(+)

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 00000000000..68025600b1f
--- /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
similarity index 98%
rename from dev-python/pypy3-exe/pypy3-exe-7.3.2.ebuild
rename to dev-python/pypy3-exe/pypy3-exe-7.3.2-r1.ebuild
index a8648c1e6ea..73313264113 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
similarity index 98%
rename from dev-python/pypy3-exe/pypy3-exe-7.3.2_p37.ebuild
rename to dev-python/pypy3-exe/pypy3-exe-7.3.2_p37-r1.ebuild
index 5992fb3e87e..592f395defc 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"


             reply	other threads:[~2020-10-04 21:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-04 21:15 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-01-09 21:59 [gentoo-commits] repo/gentoo:master commit in: dev-python/pypy3-exe/, dev-python/pypy3-exe/files/ Michał Górny
2020-10-05  1:15 Georgy Yakovlev
2020-09-17 16:56 Michał Górny
2020-02-26 12:12 David Seifert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1601846080.f0e786f0096b75d886fca041c479e936fb27e0b9.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox