summaryrefslogtreecommitdiff
path: root/dev-python/pysimdjson/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2021-05-31 20:59:14 +0100
committerV3n3RiX <venerix@redcorelinux.org>2021-05-31 20:59:14 +0100
commite748ba9741f6540f4675c23e3e37b73e822c13a4 (patch)
tree23dece8beabb3a3d7c6c0273b0eb40b21c62a889 /dev-python/pysimdjson/files
parent908778078736bd36f7a60a2d576d415cb8e000fa (diff)
gentoo resync : 31.05.2021
Diffstat (limited to 'dev-python/pysimdjson/files')
-rw-r--r--dev-python/pysimdjson/files/pysimdjson-4.0.0-error-types.patch53
-rw-r--r--dev-python/pysimdjson/files/pysimdjson-4.0.0-unbundle.patch95
2 files changed, 148 insertions, 0 deletions
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 <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):
diff --git a/dev-python/pysimdjson/files/pysimdjson-4.0.0-unbundle.patch b/dev-python/pysimdjson/files/pysimdjson-4.0.0-unbundle.patch
new file mode 100644
index 000000000000..de52bc063a24
--- /dev/null
+++ b/dev-python/pysimdjson/files/pysimdjson-4.0.0-unbundle.patch
@@ -0,0 +1,95 @@
+diff --git a/setup.py b/setup.py
+index f1de675..4c23028 100644
+--- a/setup.py
++++ b/setup.py
+@@ -27,53 +27,59 @@ if system == 'Darwin':
+ os.environ.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.14')
+ extra_compile_args.append('-std=c++11')
+
+-if os.getenv('BUILD_WITH_CYTHON') and not CYTHON_AVAILABLE:
++build_with_cython = os.getenv('BUILD_WITH_CYTHON')
++if build_with_cython and not CYTHON_AVAILABLE:
+ print(
+ 'BUILD_WITH_CYTHON environment variable is set, but cython'
+ ' is not available. Falling back to pre-cythonized version if'
+ ' available.'
+ )
++ build_with_cython = False
+
+-if os.getenv('BUILD_WITH_CYTHON') and CYTHON_AVAILABLE:
+- macros = []
+- compiler_directives = {
+- 'embedsignature': True
+- }
++build_with_system_lib = os.getenv('BUILD_WITH_SYSTEM_LIB')
++
++macros = []
++compiler_directives = {}
++libraries = []
++sources = [
++ 'simdjson/errors.cpp',
++]
++
++if build_with_system_lib:
++ libraries.append('simdjson')
++else:
++ sources.append('simdjson/simdjson.cpp')
++
++if build_with_cython:
++ compiler_directives['embedsignature'] = True
+
+ if os.getenv('BUILD_FOR_DEBUG'):
+ # Enable line tracing, which also enables support for coverage
+ # reporting.
+- macros = [
++ macros += [
+ ('CYTHON_TRACE', 1),
+ ('CYTHON_TRACE_NOGIL', 1)
+ ]
+ compiler_directives['linetrace'] = True
+
+- extensions = cythonize([
+- Extension(
+- 'csimdjson',
+- [
+- 'simdjson/simdjson.cpp',
+- 'simdjson/errors.cpp',
+- 'simdjson/csimdjson.pyx'
+- ],
+- define_macros=macros,
+- extra_compile_args=extra_compile_args
+- )
+- ], compiler_directives=compiler_directives)
++ sources.append('simdjson/csimdjson.pyx')
+ else:
+- extensions = [
+- Extension(
+- 'csimdjson',
+- [
+- 'simdjson/simdjson.cpp',
+- 'simdjson/errors.cpp',
+- 'simdjson/csimdjson.cpp'
+- ],
+- extra_compile_args=extra_compile_args,
+- language='c++'
+- )
+- ]
++ sources.append('simdjson/csimdjson.cpp')
++
++
++extensions = [
++ Extension(
++ 'csimdjson',
++ sources,
++ define_macros=macros,
++ extra_compile_args=extra_compile_args,
++ libraries=libraries,
++ language='c++',
++ )
++]
++
++if build_with_cython:
++ extensions = cythonize(extensions, compiler_directives=compiler_directives)
+
+ setup(
+ name='pysimdjson',