commit:     2c9b1b95cbd96a043d376521e5a245791db11a13
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 30 10:48:01 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Apr 30 11:06:03 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2c9b1b95

dev-python/csv23: Fix pypy3 compat

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

 dev-python/csv23/csv23-0.3.ebuild            |  6 +++-
 dev-python/csv23/files/csv23-0.3-pypy3.patch | 44 ++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/dev-python/csv23/csv23-0.3.ebuild 
b/dev-python/csv23/csv23-0.3.ebuild
index 4bb3e2569a8..82aab4ad628 100644
--- a/dev-python/csv23/csv23-0.3.ebuild
+++ b/dev-python/csv23/csv23-0.3.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-PYTHON_COMPAT=( python{2_7,3_{6,7,8}} )
+PYTHON_COMPAT=( python{2_7,3_{6,7,8}} pypy3 )
 inherit distutils-r1
 
 DESCRIPTION="Python 2/3 unicode CSV compatibility layer"
@@ -24,6 +24,10 @@ BDEPEND="
 
 distutils_enable_tests pytest
 
+PATCHES=(
+       "${FILESDIR}"/${P}-pypy3.patch
+)
+
 src_prepare() {
        sed -i -e '/--cov/d' setup.cfg || die
        distutils-r1_src_prepare

diff --git a/dev-python/csv23/files/csv23-0.3-pypy3.patch 
b/dev-python/csv23/files/csv23-0.3-pypy3.patch
new file mode 100644
index 00000000000..2e1e3b217c2
--- /dev/null
+++ b/dev-python/csv23/files/csv23-0.3-pypy3.patch
@@ -0,0 +1,44 @@
+From cb9a4519b81daccbb54ea767829d888a6b97855a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]>
+Date: Thu, 30 Apr 2020 11:54:31 +0200
+Subject: [PATCH] fix hashlib usage compatibility with pypy3
+
+PyPy3's hashlib fails when passed a memoryview object (i.e.
+BytesIO.getbuffer()).  Convert it to bytes instead in order to fix
+compatibility.  While this isn't necessary for CPython, it should not
+cause any issues.
+
+Also enabling testing with pypy3.  I had to switch to the newer Ubuntu
+version as well in order to avoid more bugs in old PyPy versions.
+
+PyPy3 bug: https://foss.heptapod.net/pypy/pypy/issues/3217
+---
+ .travis.yml        | 2 ++
+ csv23/shortcuts.py | 2 +-
+ tox.ini            | 2 +-
+ 3 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/csv23/shortcuts.py b/csv23/shortcuts.py
+index 6eeb248..7bdb013 100644
+--- a/csv23/shortcuts.py
++++ b/csv23/shortcuts.py
+@@ -206,7 +206,7 @@ def write_csv(file, rows, header=None, dialect=DIALECT, 
encoding=ENCODING,
+                 buf = f.buffer
+                 for rows in iterslices(rows, 1000):
+                     writer.writerows(rows)
+-                    hashsum.update(buf.getbuffer())
++                    hashsum.update(bytes(buf.getbuffer()))
+                     # NOTE: f.truncate(0) would prepend zero-bytes
+                     f.seek(0)
+                     f.truncate()
+diff --git a/tox.ini b/tox.ini
+index 2a234b3..89a4432 100644
+--- a/tox.ini
++++ b/tox.ini
+@@ -1,5 +1,5 @@
+ [tox]
+-envlist = py{27,35,36,37,38}
++envlist = py{27,35,36,37,38},pypy3
+ skip_missing_interpreters = true
+ 
+ [testenv]

Reply via email to