dev-python/pysimdjson: Remove old

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2021-07-24 19:33:07 +02:00
parent 9a028b5085
commit eaf5eeeb1a
3 changed files with 0 additions and 97 deletions

View File

@@ -1,2 +1 @@
DIST pysimdjson-4.0.0.tar.gz 3738787 BLAKE2B 744d6bc53511e03e8e716d6c65771432c7bf8f7876bbf8c78d09459a8b170d3d396f9cc8996894f67110f4b7389526d454dffd687b1fda22df7f76f027af44db SHA512 8b3040ce44bb5042b70a14d9f67c312a375d1a12ba7a66466935a48ad0f8def9c21e200c8c93aa755110a674e95920fa7d0567c4f584be5392b70719994a2213
DIST pysimdjson-4.0.2.tar.gz 3740054 BLAKE2B 379c8637096074615f2045171e0950af0190e8485db6a1734f4fcd19d9eeeebd91cb79c18abd2fe6256287f15aa6a3c12c1283e4affa131db14f9948ab2f0d63 SHA512 537b7958dd3429831ee201b6a4fc5fa8fca50ad14def016b472d3f234f81175441152c1823eed0bcad06f59e274e2b6b036f26a3af8f6977ceea5807471de4a5

View File

@@ -1,53 +0,0 @@
commit 1145be6cac70ed065f2053977d470f3f771ac6a0
Author: Tyler Kennedy <tk@tkte.ch>
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):

View File

@@ -1,43 +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}"/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
}