From 60eb1d1b367b61eb73875ef5fbb380079e7ce5c0 Mon Sep 17 00:00:00 2001 From: Patrick McLean Date: Mon, 24 May 2021 11:21:31 -0700 Subject: dev-python/pysimdjson-4.0.0-r1: revbump, add patch to fix issue #82 Package-Manager: Portage-3.0.19, Repoman-3.0.3 Signed-off-by: Patrick McLean --- .../files/pysimdjson-4.0.0-error-types.patch | 53 ++++++++++++++++++++++ dev-python/pysimdjson/pysimdjson-4.0.0-r1.ebuild | 43 ++++++++++++++++++ dev-python/pysimdjson/pysimdjson-4.0.0.ebuild | 42 ----------------- 3 files changed, 96 insertions(+), 42 deletions(-) create mode 100644 dev-python/pysimdjson/files/pysimdjson-4.0.0-error-types.patch create mode 100644 dev-python/pysimdjson/pysimdjson-4.0.0-r1.ebuild delete mode 100644 dev-python/pysimdjson/pysimdjson-4.0.0.ebuild (limited to 'dev-python') diff --git a/dev-python/pysimdjson/files/pysimdjson-4.0.0-error-types.patch b/dev-python/pysimdjson/files/pysimdjson-4.0.0-error-types.patch new file mode 100644 index 000000000000..34b8f4aa9e29 --- /dev/null +++ b/dev-python/pysimdjson/files/pysimdjson-4.0.0-error-types.patch @@ -0,0 +1,53 @@ +commit 1145be6cac70ed065f2053977d470f3f771ac6a0 +Author: Tyler Kennedy +Date: Sun May 23 15:55:28 2021 -0400 + + Empty buffers now raise identical error to empty bytes. Closes #81. + +diff --git a/simdjson/csimdjson.pyx b/simdjson/csimdjson.pyx +index 095a183..c278e08 100644 +--- a/simdjson/csimdjson.pyx ++++ b/simdjson/csimdjson.pyx +@@ -478,6 +478,13 @@ cdef class Parser: + # type-specific APIs, but gives much greater compatibility. + data = src + ++ if data.size == 0: ++ # If we were given a completely empty buffer, trying to access ++ # a stride in the next step will cause a (potentially ++ # confusing) IndexError. This isn't a very good error message, ++ # but it's identical to the one simdjson would have raised. ++ raise ValueError('Empty: no JSON found') ++ + return element_to_primitive( + self, + dereference(self.c_parser).parse( +diff --git a/tests/test_parser.py b/tests/test_parser.py +index 88e7207..d3a28c7 100644 +--- a/tests/test_parser.py ++++ b/tests/test_parser.py +@@ -1,3 +1,4 @@ ++import io + import pathlib + + import pytest +@@ -32,6 +33,19 @@ def test_parse_str(parser): + assert doc.as_dict() == {'hello': 'world'} + + ++def test_parse_empty_buffer(parser): ++ """Ensure trying to parse an empty buffer returns an error consistent ++ with attempting to parse an empty bytestring.""" ++ # Issue #81 ++ with pytest.raises(ValueError) as bytes_exc: ++ parser.parse(b'') ++ ++ with pytest.raises(ValueError) as buffer_exc: ++ parser.parse(io.BytesIO(b'').getbuffer()) ++ ++ assert str(bytes_exc.value) == str(buffer_exc.value) ++ ++ + def test_unicode_decode_error(parser): + """Ensure the parser raises encoding issues.""" + with pytest.raises(UnicodeDecodeError): diff --git a/dev-python/pysimdjson/pysimdjson-4.0.0-r1.ebuild b/dev-python/pysimdjson/pysimdjson-4.0.0-r1.ebuild new file mode 100644 index 000000000000..165fcadc2520 --- /dev/null +++ b/dev-python/pysimdjson/pysimdjson-4.0.0-r1.ebuild @@ -0,0 +1,43 @@ +# Copyright 2020-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7..10} ) +inherit distutils-r1 + +DESCRIPTION="Python bindings for simdjson" +HOMEPAGE="https://github.com/TkTech/pysimdjson" +SRC_URI="https://github.com/TkTech/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="MIT Apache-2.0" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +RDEPEND=" + dev-libs/simdjson:= +" +DEPEND=${RDEPEND} +BDEPEND=" + dev-python/cython[${PYTHON_USEDEP}] +" +distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}"/pysimdjson-4.0.0-unbundle.patch + "${FILESDIR}"/pysimdjson-4.0.0-error-types.patch +) + +src_prepare() { + # benchmarks aren't run + sed -i -e 's:pytest-benchmark::' setup.cfg || die + # force regen + rm simdjson/csimdjson.cpp || die + # bundled lib :-( + rm simdjson/simdjson.{cpp,h} || die + + distutils-r1_src_prepare + + export BUILD_WITH_CYTHON=1 + export BUILD_WITH_SYSTEM_LIB=1 +} diff --git a/dev-python/pysimdjson/pysimdjson-4.0.0.ebuild b/dev-python/pysimdjson/pysimdjson-4.0.0.ebuild deleted file mode 100644 index 3400cda568d5..000000000000 --- a/dev-python/pysimdjson/pysimdjson-4.0.0.ebuild +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2020-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{7..10} ) -inherit distutils-r1 - -DESCRIPTION="Python bindings for simdjson" -HOMEPAGE="https://github.com/TkTech/pysimdjson" -SRC_URI="https://github.com/TkTech/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" - -LICENSE="MIT Apache-2.0" -SLOT="0" -KEYWORDS="~amd64 ~x86" - -RDEPEND=" - dev-libs/simdjson:= -" -DEPEND=${RDEPEND} -BDEPEND=" - dev-python/cython[${PYTHON_USEDEP}] -" -distutils_enable_tests pytest - -PATCHES=( - "${FILESDIR}"/${P}-unbundle.patch -) - -src_prepare() { - # benchmarks aren't run - sed -i -e 's:pytest-benchmark::' setup.cfg || die - # force regen - rm simdjson/csimdjson.cpp || die - # bundled lib :-( - rm simdjson/simdjson.{cpp,h} || die - - distutils-r1_src_prepare - - export BUILD_WITH_CYTHON=1 - export BUILD_WITH_SYSTEM_LIB=1 -} -- cgit v1.2.3-65-gdbad