python-rapidjson 1.25__tar.gz → 1.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_rapidjson-1.25 → python_rapidjson-1.26}/CHANGES.rst +46 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/PKG-INFO +47 -1
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/changes.rst +46 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/loads.rst +10 -2
- {python_rapidjson-1.25 → python_rapidjson-1.26}/python_rapidjson.egg-info/PKG-INFO +47 -1
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson.cpp +80 -94
- {python_rapidjson-1.25 → python_rapidjson-1.26}/requirements-test.txt +4 -4
- {python_rapidjson-1.25 → python_rapidjson-1.26}/requirements.txt +3 -3
- {python_rapidjson-1.25 → python_rapidjson-1.26}/setup.py +1 -1
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_float.py +23 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_memory_leaks.py +11 -7
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_params.py +152 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_refs_count.py +3 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_streams.py +32 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_unicode.py +21 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_validator.py +37 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/.dir-locals.el +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/LICENSE +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/MANIFEST.in +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/README.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/benchmarks/conftest.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/benchmarks/tablize.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/benchmarks/test_benchmark.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/Makefile +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/api.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/benchmarks-tables.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/benchmarks.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/conf.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/decoder.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/dump.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/dumps.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/encoder.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/index.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/load.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/quickstart.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/rawjson.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/docs/validator.rst +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/python_rapidjson.egg-info/SOURCES.txt +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/python_rapidjson.egg-info/dependency_links.txt +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/python_rapidjson.egg-info/top_level.txt +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/allocators.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/cursorstreamwrapper.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/document.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/encodedstream.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/encodings.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/error/en.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/error/error.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/filereadstream.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/filewritestream.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/fwd.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/biginteger.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/clzll.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/diyfp.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/dtoa.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/ieee754.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/itoa.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/meta.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/pow10.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/regex.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/stack.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/strfunc.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/strtod.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/internal/swap.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/istreamwrapper.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/memorybuffer.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/memorystream.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/msinttypes/inttypes.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/msinttypes/stdint.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/ostreamwrapper.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/pointer.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/prettywriter.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/rapidjson.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/reader.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/schema.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/stream.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/stringbuffer.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/uri.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/include/rapidjson/writer.h +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/license.txt +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson/readme.md +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/rapidjson_exact_version.txt +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/setup.cfg +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/conftest.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_base_types.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_circular.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_dict_subclass.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_enum.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_pass1.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_pass2.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_pass3.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tests/test_rawjson.py +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/tox.ini +0 -0
- {python_rapidjson-1.25 → python_rapidjson-1.26}/typings/rapidjson/__init__.pyi +0 -0
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
Changes
|
|
2
2
|
-------
|
|
3
3
|
|
|
4
|
+
1.26 (2026-11-01)
|
|
5
|
+
~~~~~~~~~~~~~~~~~
|
|
6
|
+
|
|
7
|
+
* Add Windows ARM64 build (`PR #242`__), thanks to Nikhil Dabas
|
|
8
|
+
|
|
9
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/242
|
|
10
|
+
|
|
11
|
+
* Fix parse_mode flags without native or NaN number modes (`PR #243`__), thanks to Ryan
|
|
12
|
+
Duguid
|
|
13
|
+
|
|
14
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/243
|
|
15
|
+
|
|
16
|
+
* Validate number_mode in load and Decoder (`PR #244`__), thanks to Ryan Duguid
|
|
17
|
+
|
|
18
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/244
|
|
19
|
+
|
|
20
|
+
* Reject JSON input truncated at an embedded NUL (`PR #245`__), thanks to Michał Furgała
|
|
21
|
+
|
|
22
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/245
|
|
23
|
+
|
|
24
|
+
* Reject oversized datetime, UUID and parse mode values before narrowing them to
|
|
25
|
+
their internal representations (`PR #248`__), thanks to Luochenchen
|
|
26
|
+
|
|
27
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/248
|
|
28
|
+
|
|
29
|
+
* Generate wheels for riscv4 (`PR #249`__), thanks to Julien Stephan
|
|
30
|
+
|
|
31
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/249
|
|
32
|
+
|
|
33
|
+
* Reject embedded NUL truncation in ``Validator`` schemas and documents (`PR #250`__),
|
|
34
|
+
thanks to Jaden Fix
|
|
35
|
+
|
|
36
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/250
|
|
37
|
+
|
|
38
|
+
* Preserve the numeric locale when serializing Unix timestamps (`PR #253`__), thanks to
|
|
39
|
+
Parijat Biswas
|
|
40
|
+
|
|
41
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/253
|
|
42
|
+
|
|
43
|
+
* Normalize signed, signaling and payload-bearing Decimal NaNs to the supported
|
|
44
|
+
``NaN`` token when non-finite numbers are enabled, so encoded output remains
|
|
45
|
+
readable by the decoder (`PR #255`__), thanks to Rupayon Haldar
|
|
46
|
+
|
|
47
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/255
|
|
48
|
+
|
|
49
|
+
|
|
4
50
|
1.25 (2026-09-06)
|
|
5
51
|
~~~~~~~~~~~~~~~~~
|
|
6
52
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-rapidjson
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.26
|
|
4
4
|
Summary: Python wrapper around rapidjson
|
|
5
5
|
Home-page: https://github.com/python-rapidjson/python-rapidjson
|
|
6
6
|
Author: Ken Robbins
|
|
@@ -188,6 +188,52 @@ __ https://python-rapidjson.readthedocs.io/en/latest/quickstart.html#incompatibi
|
|
|
188
188
|
Changes
|
|
189
189
|
-------
|
|
190
190
|
|
|
191
|
+
1.26 (2026-11-01)
|
|
192
|
+
~~~~~~~~~~~~~~~~~
|
|
193
|
+
|
|
194
|
+
* Add Windows ARM64 build (`PR #242`__), thanks to Nikhil Dabas
|
|
195
|
+
|
|
196
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/242
|
|
197
|
+
|
|
198
|
+
* Fix parse_mode flags without native or NaN number modes (`PR #243`__), thanks to Ryan
|
|
199
|
+
Duguid
|
|
200
|
+
|
|
201
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/243
|
|
202
|
+
|
|
203
|
+
* Validate number_mode in load and Decoder (`PR #244`__), thanks to Ryan Duguid
|
|
204
|
+
|
|
205
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/244
|
|
206
|
+
|
|
207
|
+
* Reject JSON input truncated at an embedded NUL (`PR #245`__), thanks to Michał Furgała
|
|
208
|
+
|
|
209
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/245
|
|
210
|
+
|
|
211
|
+
* Reject oversized datetime, UUID and parse mode values before narrowing them to
|
|
212
|
+
their internal representations (`PR #248`__), thanks to Luochenchen
|
|
213
|
+
|
|
214
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/248
|
|
215
|
+
|
|
216
|
+
* Generate wheels for riscv4 (`PR #249`__), thanks to Julien Stephan
|
|
217
|
+
|
|
218
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/249
|
|
219
|
+
|
|
220
|
+
* Reject embedded NUL truncation in ``Validator`` schemas and documents (`PR #250`__),
|
|
221
|
+
thanks to Jaden Fix
|
|
222
|
+
|
|
223
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/250
|
|
224
|
+
|
|
225
|
+
* Preserve the numeric locale when serializing Unix timestamps (`PR #253`__), thanks to
|
|
226
|
+
Parijat Biswas
|
|
227
|
+
|
|
228
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/253
|
|
229
|
+
|
|
230
|
+
* Normalize signed, signaling and payload-bearing Decimal NaNs to the supported
|
|
231
|
+
``NaN`` token when non-finite numbers are enabled, so encoded output remains
|
|
232
|
+
readable by the decoder (`PR #255`__), thanks to Rupayon Haldar
|
|
233
|
+
|
|
234
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/255
|
|
235
|
+
|
|
236
|
+
|
|
191
237
|
1.25 (2026-09-06)
|
|
192
238
|
~~~~~~~~~~~~~~~~~
|
|
193
239
|
|
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
Changes
|
|
2
2
|
-------
|
|
3
3
|
|
|
4
|
+
1.26 (2026-11-01)
|
|
5
|
+
~~~~~~~~~~~~~~~~~
|
|
6
|
+
|
|
7
|
+
* Add Windows ARM64 build (`PR #242`__), thanks to Nikhil Dabas
|
|
8
|
+
|
|
9
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/242
|
|
10
|
+
|
|
11
|
+
* Fix parse_mode flags without native or NaN number modes (`PR #243`__), thanks to Ryan
|
|
12
|
+
Duguid
|
|
13
|
+
|
|
14
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/243
|
|
15
|
+
|
|
16
|
+
* Validate number_mode in load and Decoder (`PR #244`__), thanks to Ryan Duguid
|
|
17
|
+
|
|
18
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/244
|
|
19
|
+
|
|
20
|
+
* Reject JSON input truncated at an embedded NUL (`PR #245`__), thanks to Michał Furgała
|
|
21
|
+
|
|
22
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/245
|
|
23
|
+
|
|
24
|
+
* Reject oversized datetime, UUID and parse mode values before narrowing them to
|
|
25
|
+
their internal representations (`PR #248`__), thanks to Luochenchen
|
|
26
|
+
|
|
27
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/248
|
|
28
|
+
|
|
29
|
+
* Generate wheels for riscv4 (`PR #249`__), thanks to Julien Stephan
|
|
30
|
+
|
|
31
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/249
|
|
32
|
+
|
|
33
|
+
* Reject embedded NUL truncation in ``Validator`` schemas and documents (`PR #250`__),
|
|
34
|
+
thanks to Jaden Fix
|
|
35
|
+
|
|
36
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/250
|
|
37
|
+
|
|
38
|
+
* Preserve the numeric locale when serializing Unix timestamps (`PR #253`__), thanks to
|
|
39
|
+
Parijat Biswas
|
|
40
|
+
|
|
41
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/253
|
|
42
|
+
|
|
43
|
+
* Normalize signed, signaling and payload-bearing Decimal NaNs to the supported
|
|
44
|
+
``NaN`` token when non-finite numbers are enabled, so encoded output remains
|
|
45
|
+
readable by the decoder (`PR #255`__), thanks to Rupayon Haldar
|
|
46
|
+
|
|
47
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/255
|
|
48
|
+
|
|
49
|
+
|
|
4
50
|
1.25 (2026-09-06)
|
|
5
51
|
~~~~~~~~~~~~~~~~~
|
|
6
52
|
|
|
@@ -113,8 +113,16 @@
|
|
|
113
113
|
|
|
114
114
|
>>> loads('123456789012345678901234567890')
|
|
115
115
|
123456789012345678901234567890
|
|
116
|
-
>>>
|
|
117
|
-
|
|
116
|
+
>>> import math
|
|
117
|
+
>>> native = loads('123456789012345678901234567890', number_mode=NM_NATIVE)
|
|
118
|
+
>>> isinstance(native, float)
|
|
119
|
+
True
|
|
120
|
+
>>> math.isclose(native, float(123456789012345678901234567890),
|
|
121
|
+
... rel_tol=0, abs_tol=math.ulp(native))
|
|
122
|
+
True
|
|
123
|
+
|
|
124
|
+
The final bit of the rounded ``double`` can differ between platforms; the example
|
|
125
|
+
permits a difference of one unit in the last place while requiring a ``float``.
|
|
118
126
|
|
|
119
127
|
These flags can be combined together:
|
|
120
128
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-rapidjson
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.26
|
|
4
4
|
Summary: Python wrapper around rapidjson
|
|
5
5
|
Home-page: https://github.com/python-rapidjson/python-rapidjson
|
|
6
6
|
Author: Ken Robbins
|
|
@@ -188,6 +188,52 @@ __ https://python-rapidjson.readthedocs.io/en/latest/quickstart.html#incompatibi
|
|
|
188
188
|
Changes
|
|
189
189
|
-------
|
|
190
190
|
|
|
191
|
+
1.26 (2026-11-01)
|
|
192
|
+
~~~~~~~~~~~~~~~~~
|
|
193
|
+
|
|
194
|
+
* Add Windows ARM64 build (`PR #242`__), thanks to Nikhil Dabas
|
|
195
|
+
|
|
196
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/242
|
|
197
|
+
|
|
198
|
+
* Fix parse_mode flags without native or NaN number modes (`PR #243`__), thanks to Ryan
|
|
199
|
+
Duguid
|
|
200
|
+
|
|
201
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/243
|
|
202
|
+
|
|
203
|
+
* Validate number_mode in load and Decoder (`PR #244`__), thanks to Ryan Duguid
|
|
204
|
+
|
|
205
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/244
|
|
206
|
+
|
|
207
|
+
* Reject JSON input truncated at an embedded NUL (`PR #245`__), thanks to Michał Furgała
|
|
208
|
+
|
|
209
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/245
|
|
210
|
+
|
|
211
|
+
* Reject oversized datetime, UUID and parse mode values before narrowing them to
|
|
212
|
+
their internal representations (`PR #248`__), thanks to Luochenchen
|
|
213
|
+
|
|
214
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/248
|
|
215
|
+
|
|
216
|
+
* Generate wheels for riscv4 (`PR #249`__), thanks to Julien Stephan
|
|
217
|
+
|
|
218
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/249
|
|
219
|
+
|
|
220
|
+
* Reject embedded NUL truncation in ``Validator`` schemas and documents (`PR #250`__),
|
|
221
|
+
thanks to Jaden Fix
|
|
222
|
+
|
|
223
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/250
|
|
224
|
+
|
|
225
|
+
* Preserve the numeric locale when serializing Unix timestamps (`PR #253`__), thanks to
|
|
226
|
+
Parijat Biswas
|
|
227
|
+
|
|
228
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/253
|
|
229
|
+
|
|
230
|
+
* Normalize signed, signaling and payload-bearing Decimal NaNs to the supported
|
|
231
|
+
``NaN`` token when non-finite numbers are enabled, so encoded output remains
|
|
232
|
+
readable by the decoder (`PR #255`__), thanks to Rupayon Haldar
|
|
233
|
+
|
|
234
|
+
__ https://github.com/python-rapidjson/python-rapidjson/pull/255
|
|
235
|
+
|
|
236
|
+
|
|
191
237
|
1.25 (2026-09-06)
|
|
192
238
|
~~~~~~~~~~~~~~~~~
|
|
193
239
|
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
// :Copyright: © 2015-2026 Lele Gaifax
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#include <locale.h>
|
|
10
|
-
|
|
11
9
|
#include <Python.h>
|
|
12
10
|
#include <datetime.h>
|
|
13
11
|
#include <structmember.h>
|
|
@@ -113,7 +111,7 @@ datetime_mode_format(unsigned mode) {
|
|
|
113
111
|
|
|
114
112
|
|
|
115
113
|
static inline bool
|
|
116
|
-
valid_datetime_mode(
|
|
114
|
+
valid_datetime_mode(long mode) {
|
|
117
115
|
int format = datetime_mode_format(mode);
|
|
118
116
|
return (mode >= 0 && mode < DM_MAX
|
|
119
117
|
&& (format <= DM_UNIX_TIME)
|
|
@@ -276,6 +274,10 @@ public:
|
|
|
276
274
|
return offset + pos;
|
|
277
275
|
}
|
|
278
276
|
|
|
277
|
+
bool IsEnd() const {
|
|
278
|
+
return eof;
|
|
279
|
+
}
|
|
280
|
+
|
|
279
281
|
void Flush() {
|
|
280
282
|
assert(false);
|
|
281
283
|
}
|
|
@@ -1769,35 +1771,19 @@ load(PyObject* self, PyObject* args, PyObject* kwargs)
|
|
|
1769
1771
|
}
|
|
1770
1772
|
}
|
|
1771
1773
|
|
|
1772
|
-
if (numberModeObj)
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
PyErr_SetString(PyExc_ValueError, "Invalid number_mode");
|
|
1779
|
-
return NULL;
|
|
1780
|
-
}
|
|
1781
|
-
numberMode = (unsigned) mode;
|
|
1782
|
-
if (numberMode & NM_DECIMAL && numberMode & NM_NATIVE) {
|
|
1783
|
-
PyErr_SetString(PyExc_ValueError,
|
|
1784
|
-
"Combining NM_NATIVE with NM_DECIMAL is not supported");
|
|
1785
|
-
return NULL;
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
if (allowNan != -1) {
|
|
1790
|
-
if (allowNan)
|
|
1791
|
-
numberMode |= NM_NAN;
|
|
1792
|
-
else
|
|
1793
|
-
numberMode &= ~NM_NAN;
|
|
1774
|
+
if (!accept_number_mode_arg(numberModeObj, allowNan, numberMode))
|
|
1775
|
+
return NULL;
|
|
1776
|
+
if (numberMode & NM_DECIMAL && numberMode & NM_NATIVE) {
|
|
1777
|
+
PyErr_SetString(PyExc_ValueError,
|
|
1778
|
+
"Combining NM_NATIVE with NM_DECIMAL is not supported");
|
|
1779
|
+
return NULL;
|
|
1794
1780
|
}
|
|
1795
1781
|
|
|
1796
1782
|
if (datetimeModeObj) {
|
|
1797
1783
|
if (datetimeModeObj == Py_None) {
|
|
1798
1784
|
datetimeMode = DM_NONE;
|
|
1799
1785
|
} else if (PyLong_Check(datetimeModeObj)) {
|
|
1800
|
-
|
|
1786
|
+
long mode = PyLong_AsLong(datetimeModeObj);
|
|
1801
1787
|
if (!valid_datetime_mode(mode)) {
|
|
1802
1788
|
PyErr_SetString(PyExc_ValueError, "Invalid datetime_mode");
|
|
1803
1789
|
return NULL;
|
|
@@ -1820,7 +1806,7 @@ load(PyObject* self, PyObject* args, PyObject* kwargs)
|
|
|
1820
1806
|
if (uuidModeObj == Py_None) {
|
|
1821
1807
|
uuidMode = UM_NONE;
|
|
1822
1808
|
} else if (PyLong_Check(uuidModeObj)) {
|
|
1823
|
-
|
|
1809
|
+
long mode = PyLong_AsLong(uuidModeObj);
|
|
1824
1810
|
if (mode < 0 || mode >= UM_MAX) {
|
|
1825
1811
|
PyErr_SetString(PyExc_ValueError, "Invalid uuid_mode");
|
|
1826
1812
|
return NULL;
|
|
@@ -1837,7 +1823,7 @@ load(PyObject* self, PyObject* args, PyObject* kwargs)
|
|
|
1837
1823
|
if (parseModeObj == Py_None) {
|
|
1838
1824
|
parseMode = PM_NONE;
|
|
1839
1825
|
} else if (PyLong_Check(parseModeObj)) {
|
|
1840
|
-
|
|
1826
|
+
long mode = PyLong_AsLong(parseModeObj);
|
|
1841
1827
|
if (mode < 0 || mode >= PM_MAX) {
|
|
1842
1828
|
PyErr_SetString(PyExc_ValueError, "Invalid parse_mode");
|
|
1843
1829
|
return NULL;
|
|
@@ -2029,12 +2015,17 @@ static PyTypeObject Decoder_Type = {
|
|
|
2029
2015
|
if (parseMode & PM_COMMENTS) { \
|
|
2030
2016
|
r.Parse<f | \
|
|
2031
2017
|
kParseCommentsFlag | \
|
|
2032
|
-
kParseNumbersAsStringsFlag
|
|
2018
|
+
kParseNumbersAsStringsFlag | \
|
|
2019
|
+
kParseTrailingCommasFlag>(s, h); \
|
|
2033
2020
|
} else { \
|
|
2034
2021
|
r.Parse<f | \
|
|
2035
2022
|
kParseNumbersAsStringsFlag | \
|
|
2036
2023
|
kParseTrailingCommasFlag>(s, h); \
|
|
2037
2024
|
} \
|
|
2025
|
+
} else if (parseMode & PM_COMMENTS) { \
|
|
2026
|
+
r.Parse<f | \
|
|
2027
|
+
kParseNumbersAsStringsFlag | \
|
|
2028
|
+
kParseCommentsFlag>(s, h); \
|
|
2038
2029
|
} else { \
|
|
2039
2030
|
r.Parse<f | kParseNumbersAsStringsFlag>(s, h); \
|
|
2040
2031
|
} \
|
|
@@ -2049,6 +2040,7 @@ do_decode(PyObject* decoder, const char* jsonStr, Py_ssize_t jsonStrLen,
|
|
|
2049
2040
|
{
|
|
2050
2041
|
PyHandler handler(decoder, objectHook, datetimeMode, uuidMode, numberMode);
|
|
2051
2042
|
Reader reader;
|
|
2043
|
+
ParseResult result;
|
|
2052
2044
|
|
|
2053
2045
|
if (jsonStr != NULL) {
|
|
2054
2046
|
char* jsonStrCopy = (char*) PyMem_Malloc(sizeof(char) * (jsonStrLen+1));
|
|
@@ -2062,15 +2054,23 @@ do_decode(PyObject* decoder, const char* jsonStr, Py_ssize_t jsonStrLen,
|
|
|
2062
2054
|
|
|
2063
2055
|
DECODE(reader, kParseInsituFlag, ss, handler);
|
|
2064
2056
|
|
|
2057
|
+
result.Set(reader.GetParseErrorCode(), reader.GetErrorOffset());
|
|
2058
|
+
if (!result.IsError() && ss.Tell() < (size_t) jsonStrLen)
|
|
2059
|
+
result.Set(kParseErrorDocumentRootNotSingular, ss.Tell());
|
|
2060
|
+
|
|
2065
2061
|
PyMem_Free(jsonStrCopy);
|
|
2066
2062
|
} else {
|
|
2067
2063
|
PyReadStreamWrapper sw(jsonStream, chunkSize);
|
|
2068
2064
|
|
|
2069
2065
|
DECODE(reader, kParseNoFlags, sw, handler);
|
|
2066
|
+
|
|
2067
|
+
result.Set(reader.GetParseErrorCode(), reader.GetErrorOffset());
|
|
2068
|
+
if (!result.IsError() && !sw.IsEnd())
|
|
2069
|
+
result.Set(kParseErrorDocumentRootNotSingular, sw.Tell());
|
|
2070
2070
|
}
|
|
2071
2071
|
|
|
2072
|
-
if (
|
|
2073
|
-
size_t offset =
|
|
2072
|
+
if (result.IsError()) {
|
|
2073
|
+
size_t offset = result.Offset();
|
|
2074
2074
|
|
|
2075
2075
|
if (PyErr_Occurred()) {
|
|
2076
2076
|
PyObject* etype;
|
|
@@ -2092,7 +2092,7 @@ do_decode(PyObject* decoder, const char* jsonStr, Py_ssize_t jsonStrLen,
|
|
|
2092
2092
|
}
|
|
2093
2093
|
else
|
|
2094
2094
|
PyErr_Format(decode_error, "Parse error at offset %zu: %s",
|
|
2095
|
-
offset, GetParseError_En(
|
|
2095
|
+
offset, GetParseError_En(result.Code()));
|
|
2096
2096
|
|
|
2097
2097
|
Py_XDECREF(handler.root);
|
|
2098
2098
|
return NULL;
|
|
@@ -2209,29 +2209,19 @@ decoder_new(PyTypeObject* type, PyObject* args, PyObject* kwargs)
|
|
|
2209
2209
|
&parseModeObj))
|
|
2210
2210
|
return NULL;
|
|
2211
2211
|
|
|
2212
|
-
if (numberModeObj)
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
PyErr_SetString(PyExc_ValueError, "Invalid number_mode");
|
|
2219
|
-
return NULL;
|
|
2220
|
-
}
|
|
2221
|
-
numberMode = (unsigned) mode;
|
|
2222
|
-
if (numberMode & NM_DECIMAL && numberMode & NM_NATIVE) {
|
|
2223
|
-
PyErr_SetString(PyExc_ValueError,
|
|
2224
|
-
"Combining NM_NATIVE with NM_DECIMAL is not supported");
|
|
2225
|
-
return NULL;
|
|
2226
|
-
}
|
|
2227
|
-
}
|
|
2212
|
+
if (!accept_number_mode_arg(numberModeObj, -1, numberMode))
|
|
2213
|
+
return NULL;
|
|
2214
|
+
if (numberMode & NM_DECIMAL && numberMode & NM_NATIVE) {
|
|
2215
|
+
PyErr_SetString(PyExc_ValueError,
|
|
2216
|
+
"Combining NM_NATIVE with NM_DECIMAL is not supported");
|
|
2217
|
+
return NULL;
|
|
2228
2218
|
}
|
|
2229
2219
|
|
|
2230
2220
|
if (datetimeModeObj) {
|
|
2231
2221
|
if (datetimeModeObj == Py_None) {
|
|
2232
2222
|
datetimeMode = DM_NONE;
|
|
2233
2223
|
} else if (PyLong_Check(datetimeModeObj)) {
|
|
2234
|
-
|
|
2224
|
+
long mode = PyLong_AsLong(datetimeModeObj);
|
|
2235
2225
|
if (!valid_datetime_mode(mode)) {
|
|
2236
2226
|
PyErr_SetString(PyExc_ValueError, "Invalid datetime_mode");
|
|
2237
2227
|
return NULL;
|
|
@@ -2254,7 +2244,7 @@ decoder_new(PyTypeObject* type, PyObject* args, PyObject* kwargs)
|
|
|
2254
2244
|
if (uuidModeObj == Py_None) {
|
|
2255
2245
|
uuidMode = UM_NONE;
|
|
2256
2246
|
} else if (PyLong_Check(uuidModeObj)) {
|
|
2257
|
-
|
|
2247
|
+
long mode = PyLong_AsLong(uuidModeObj);
|
|
2258
2248
|
if (mode < 0 || mode >= UM_MAX) {
|
|
2259
2249
|
PyErr_SetString(PyExc_ValueError, "Invalid uuid_mode");
|
|
2260
2250
|
return NULL;
|
|
@@ -2271,7 +2261,7 @@ decoder_new(PyTypeObject* type, PyObject* args, PyObject* kwargs)
|
|
|
2271
2261
|
if (parseModeObj == Py_None) {
|
|
2272
2262
|
parseMode = PM_NONE;
|
|
2273
2263
|
} else if (PyLong_Check(parseModeObj)) {
|
|
2274
|
-
|
|
2264
|
+
long mode = PyLong_AsLong(parseModeObj);
|
|
2275
2265
|
if (mode < 0 || mode >= PM_MAX) {
|
|
2276
2266
|
PyErr_SetString(PyExc_ValueError, "Invalid parse_mode");
|
|
2277
2267
|
return NULL;
|
|
@@ -2395,6 +2385,19 @@ dumps_internal(
|
|
|
2395
2385
|
}
|
|
2396
2386
|
}
|
|
2397
2387
|
|
|
2388
|
+
if (numberMode & NM_NAN) {
|
|
2389
|
+
PyObject* is_nan = PyObject_CallMethodObjArgs(object, is_nan_name,
|
|
2390
|
+
NULL);
|
|
2391
|
+
if (is_nan == NULL)
|
|
2392
|
+
return false;
|
|
2393
|
+
bool nan = is_nan == Py_True;
|
|
2394
|
+
Py_DECREF(is_nan);
|
|
2395
|
+
if (nan) {
|
|
2396
|
+
writer->RawValue("NaN", 3, kNumberType);
|
|
2397
|
+
return PyErr_Occurred() ? false : true;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2398
2401
|
PyObject* decStrObj = PyObject_Str(object);
|
|
2399
2402
|
if (decStrObj == NULL)
|
|
2400
2403
|
return false;
|
|
@@ -2813,30 +2816,18 @@ dumps_internal(
|
|
|
2813
2816
|
if (datetimeMode & DM_ONLY_SECONDS) {
|
|
2814
2817
|
writer->Int64((int64_t) timestamp);
|
|
2815
2818
|
} else {
|
|
2816
|
-
//
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
//
|
|
2824
|
-
// can only imagine that recent Sphinx (that is, 4.2+) initializes the
|
|
2825
|
-
// locale to something that implies a decimal separator different from
|
|
2826
|
-
// a dot ".", say a comma "," when LANG is "it_IT"... not the best
|
|
2827
|
-
// thing to do when emitting JSON!
|
|
2828
|
-
|
|
2829
|
-
const char* locale = setlocale(LC_NUMERIC, NULL);
|
|
2830
|
-
setlocale(LC_NUMERIC, "C");
|
|
2831
|
-
|
|
2832
|
-
int size = snprintf(tsStr, 12 + 1 + 6, "%.6f", timestamp);
|
|
2833
|
-
|
|
2834
|
-
setlocale(LC_NUMERIC, locale);
|
|
2835
|
-
|
|
2836
|
-
// Remove trailing 0s
|
|
2819
|
+
// Keep microsecond precision without changing the process locale.
|
|
2820
|
+
char* tsStr = PyOS_double_to_string(timestamp, 'f', 6, 0, NULL);
|
|
2821
|
+
if (tsStr == NULL) {
|
|
2822
|
+
Py_XDECREF(asUTC);
|
|
2823
|
+
return false;
|
|
2824
|
+
}
|
|
2825
|
+
size_t size = strlen(tsStr);
|
|
2826
|
+
// Keep one fractional digit, as before.
|
|
2837
2827
|
while (tsStr[size-2] != '.' && tsStr[size-1] == '0')
|
|
2838
2828
|
size--;
|
|
2839
2829
|
writer->RawValue(tsStr, size, kNumberType);
|
|
2830
|
+
PyMem_Free(tsStr);
|
|
2840
2831
|
}
|
|
2841
2832
|
} else {
|
|
2842
2833
|
hour = PyDateTime_TIME_GET_HOUR(dtObject);
|
|
@@ -2900,25 +2891,16 @@ dumps_internal(
|
|
|
2900
2891
|
if (datetimeMode & DM_ONLY_SECONDS) {
|
|
2901
2892
|
writer->Int64((int64_t) timestamp);
|
|
2902
2893
|
} else {
|
|
2903
|
-
//
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
// Temporarily switch to a POSIX locale, in case the outer
|
|
2910
|
-
// world is configured differently, see above
|
|
2911
|
-
|
|
2912
|
-
const char* locale = setlocale(LC_NUMERIC, NULL);
|
|
2913
|
-
setlocale(LC_NUMERIC, "C");
|
|
2914
|
-
|
|
2915
|
-
setlocale(LC_NUMERIC, locale);
|
|
2916
|
-
|
|
2917
|
-
int size = snprintf(tsStr, 12 + 1 + 6, "%.6f", timestamp);
|
|
2918
|
-
// Remove trailing 0s
|
|
2894
|
+
// Keep microsecond precision without changing the process locale.
|
|
2895
|
+
char* tsStr = PyOS_double_to_string(timestamp, 'f', 6, 0, NULL);
|
|
2896
|
+
if (tsStr == NULL)
|
|
2897
|
+
return false;
|
|
2898
|
+
size_t size = strlen(tsStr);
|
|
2899
|
+
// Keep one fractional digit, as before.
|
|
2919
2900
|
while (tsStr[size-2] != '.' && tsStr[size-1] == '0')
|
|
2920
2901
|
size--;
|
|
2921
2902
|
writer->RawValue(tsStr, size, kNumberType);
|
|
2903
|
+
PyMem_Free(tsStr);
|
|
2922
2904
|
}
|
|
2923
2905
|
}
|
|
2924
2906
|
} else if (uuidMode != UM_NONE
|
|
@@ -3724,17 +3706,18 @@ static PyObject* validator_call(PyObject* self, PyObject* args, PyObject* kwargs
|
|
|
3724
3706
|
return NULL;
|
|
3725
3707
|
|
|
3726
3708
|
const char* jsonStr;
|
|
3709
|
+
Py_ssize_t jsonStrLen;
|
|
3727
3710
|
PyObject* asUnicode = NULL;
|
|
3728
3711
|
|
|
3729
3712
|
if (PyUnicode_Check(jsonObject)) {
|
|
3730
|
-
jsonStr =
|
|
3713
|
+
jsonStr = PyUnicode_AsUTF8AndSize(jsonObject, &jsonStrLen);
|
|
3731
3714
|
if (jsonStr == NULL)
|
|
3732
3715
|
return NULL;
|
|
3733
3716
|
} else if (PyBytes_Check(jsonObject) || PyByteArray_Check(jsonObject)) {
|
|
3734
3717
|
asUnicode = PyUnicode_FromEncodedObject(jsonObject, "utf-8", NULL);
|
|
3735
3718
|
if (asUnicode == NULL)
|
|
3736
3719
|
return NULL;
|
|
3737
|
-
jsonStr =
|
|
3720
|
+
jsonStr = PyUnicode_AsUTF8AndSize(asUnicode, &jsonStrLen);
|
|
3738
3721
|
if (jsonStr == NULL) {
|
|
3739
3722
|
Py_DECREF(asUnicode);
|
|
3740
3723
|
return NULL;
|
|
@@ -3749,7 +3732,8 @@ static PyObject* validator_call(PyObject* self, PyObject* args, PyObject* kwargs
|
|
|
3749
3732
|
bool error;
|
|
3750
3733
|
|
|
3751
3734
|
Py_BEGIN_ALLOW_THREADS
|
|
3752
|
-
|
|
3735
|
+
StringStream stream(jsonStr);
|
|
3736
|
+
error = d.ParseStream(stream).HasParseError() || stream.Tell() < (size_t) jsonStrLen;
|
|
3753
3737
|
Py_END_ALLOW_THREADS
|
|
3754
3738
|
|
|
3755
3739
|
if (error) {
|
|
@@ -3811,17 +3795,18 @@ static PyObject* validator_new(PyTypeObject* type, PyObject* args, PyObject* kwa
|
|
|
3811
3795
|
return NULL;
|
|
3812
3796
|
|
|
3813
3797
|
const char* jsonStr;
|
|
3798
|
+
Py_ssize_t jsonStrLen;
|
|
3814
3799
|
PyObject* asUnicode = NULL;
|
|
3815
3800
|
|
|
3816
3801
|
if (PyUnicode_Check(jsonObject)) {
|
|
3817
|
-
jsonStr =
|
|
3802
|
+
jsonStr = PyUnicode_AsUTF8AndSize(jsonObject, &jsonStrLen);
|
|
3818
3803
|
if (jsonStr == NULL)
|
|
3819
3804
|
return NULL;
|
|
3820
3805
|
} else if (PyBytes_Check(jsonObject) || PyByteArray_Check(jsonObject)) {
|
|
3821
3806
|
asUnicode = PyUnicode_FromEncodedObject(jsonObject, "utf-8", NULL);
|
|
3822
3807
|
if (asUnicode == NULL)
|
|
3823
3808
|
return NULL;
|
|
3824
|
-
jsonStr =
|
|
3809
|
+
jsonStr = PyUnicode_AsUTF8AndSize(asUnicode, &jsonStrLen);
|
|
3825
3810
|
if (jsonStr == NULL) {
|
|
3826
3811
|
Py_DECREF(asUnicode);
|
|
3827
3812
|
return NULL;
|
|
@@ -3836,7 +3821,8 @@ static PyObject* validator_new(PyTypeObject* type, PyObject* args, PyObject* kwa
|
|
|
3836
3821
|
bool error;
|
|
3837
3822
|
|
|
3838
3823
|
Py_BEGIN_ALLOW_THREADS
|
|
3839
|
-
|
|
3824
|
+
StringStream stream(jsonStr);
|
|
3825
|
+
error = d.ParseStream(stream).HasParseError() || stream.Tell() < (size_t) jsonStrLen;
|
|
3840
3826
|
Py_END_ALLOW_THREADS
|
|
3841
3827
|
|
|
3842
3828
|
if (asUnicode != NULL)
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
setuptools
|
|
12
12
|
|
|
13
13
|
# Needed by make release
|
|
14
|
-
bump-my-version==1.
|
|
15
|
-
readme-renderer==
|
|
14
|
+
bump-my-version==1.7.0
|
|
15
|
+
readme-renderer==46.0
|
|
16
16
|
twine==7.0.0
|
|
17
17
|
|
|
18
18
|
# Needed by make benchmarks-*
|
|
19
|
-
pytest-benchmark==5.
|
|
19
|
+
pytest-benchmark==5.3.1
|
|
20
20
|
|
|
21
21
|
pysimdjson==7.0.2
|
|
22
22
|
orjson==3.12.0
|
|
@@ -14,6 +14,29 @@ import pytest
|
|
|
14
14
|
import rapidjson as rj
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
@pytest.mark.parametrize('value', [
|
|
18
|
+
'NaN', '-NaN', '+NaN', 'sNaN', '-sNaN', '+sNaN', 'NaN123', '-NaN123',
|
|
19
|
+
])
|
|
20
|
+
@pytest.mark.parametrize('use_encoder', [False, True])
|
|
21
|
+
def test_decimal_nan_tokens(value, use_encoder):
|
|
22
|
+
number = Decimal(value)
|
|
23
|
+
mode = rj.NM_DECIMAL | rj.NM_NAN
|
|
24
|
+
encode = rj.Encoder(number_mode=mode) if use_encoder else (
|
|
25
|
+
lambda obj: rj.dumps(obj, number_mode=mode)
|
|
26
|
+
)
|
|
27
|
+
assert encode(number) == 'NaN'
|
|
28
|
+
encoded = encode({'value': [number]})
|
|
29
|
+
decoded = rj.loads(encoded, number_mode=mode)
|
|
30
|
+
assert decoded['value'][0].is_nan()
|
|
31
|
+
|
|
32
|
+
if use_encoder:
|
|
33
|
+
strict_encode = rj.Encoder(number_mode=rj.NM_DECIMAL)
|
|
34
|
+
else:
|
|
35
|
+
strict_encode = lambda obj: rj.dumps(obj, number_mode=rj.NM_DECIMAL)
|
|
36
|
+
with pytest.raises(ValueError, match='Out of range decimal'):
|
|
37
|
+
strict_encode(number)
|
|
38
|
+
|
|
39
|
+
|
|
17
40
|
def test_infinity_f():
|
|
18
41
|
inf = float("inf")
|
|
19
42
|
|