python-rapidjson 1.19__tar.gz → 1.20__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.
Files changed (95) hide show
  1. {python-rapidjson-1.19 → python_rapidjson-1.20}/CHANGES.rst +14 -0
  2. {python-rapidjson-1.19 → python_rapidjson-1.20}/PKG-INFO +15 -1
  3. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/changes.rst +14 -0
  4. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/validator.rst +3 -3
  5. {python-rapidjson-1.19 → python_rapidjson-1.20}/python_rapidjson.egg-info/PKG-INFO +15 -1
  6. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson.cpp +40 -15
  7. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_base_types.py +14 -1
  8. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_validator.py +5 -3
  9. {python-rapidjson-1.19 → python_rapidjson-1.20}/typings/rapidjson/__init__.pyi +4 -4
  10. python_rapidjson-1.20/version.txt +1 -0
  11. python-rapidjson-1.19/version.txt +0 -1
  12. {python-rapidjson-1.19 → python_rapidjson-1.20}/.dir-locals.el +0 -0
  13. {python-rapidjson-1.19 → python_rapidjson-1.20}/LICENSE +0 -0
  14. {python-rapidjson-1.19 → python_rapidjson-1.20}/MANIFEST.in +0 -0
  15. {python-rapidjson-1.19 → python_rapidjson-1.20}/README.rst +0 -0
  16. {python-rapidjson-1.19 → python_rapidjson-1.20}/benchmarks/conftest.py +0 -0
  17. {python-rapidjson-1.19 → python_rapidjson-1.20}/benchmarks/tablize.py +0 -0
  18. {python-rapidjson-1.19 → python_rapidjson-1.20}/benchmarks/test_benchmark.py +0 -0
  19. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/Makefile +0 -0
  20. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/api.rst +0 -0
  21. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/benchmarks-tables.rst +0 -0
  22. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/benchmarks.rst +0 -0
  23. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/conf.py +0 -0
  24. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/decoder.rst +0 -0
  25. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/dump.rst +0 -0
  26. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/dumps.rst +0 -0
  27. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/encoder.rst +0 -0
  28. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/index.rst +0 -0
  29. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/load.rst +0 -0
  30. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/loads.rst +0 -0
  31. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/quickstart.rst +0 -0
  32. {python-rapidjson-1.19 → python_rapidjson-1.20}/docs/rawjson.rst +0 -0
  33. {python-rapidjson-1.19 → python_rapidjson-1.20}/python_rapidjson.egg-info/SOURCES.txt +0 -0
  34. {python-rapidjson-1.19 → python_rapidjson-1.20}/python_rapidjson.egg-info/dependency_links.txt +0 -0
  35. {python-rapidjson-1.19 → python_rapidjson-1.20}/python_rapidjson.egg-info/top_level.txt +0 -0
  36. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/allocators.h +0 -0
  37. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/cursorstreamwrapper.h +0 -0
  38. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/document.h +0 -0
  39. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/encodedstream.h +0 -0
  40. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/encodings.h +0 -0
  41. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/error/en.h +0 -0
  42. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/error/error.h +0 -0
  43. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/filereadstream.h +0 -0
  44. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/filewritestream.h +0 -0
  45. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/fwd.h +0 -0
  46. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/biginteger.h +0 -0
  47. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/clzll.h +0 -0
  48. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/diyfp.h +0 -0
  49. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/dtoa.h +0 -0
  50. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/ieee754.h +0 -0
  51. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/itoa.h +0 -0
  52. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/meta.h +0 -0
  53. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/pow10.h +0 -0
  54. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/regex.h +0 -0
  55. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/stack.h +0 -0
  56. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/strfunc.h +0 -0
  57. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/strtod.h +0 -0
  58. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/internal/swap.h +0 -0
  59. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/istreamwrapper.h +0 -0
  60. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/memorybuffer.h +0 -0
  61. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/memorystream.h +0 -0
  62. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/msinttypes/inttypes.h +0 -0
  63. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/msinttypes/stdint.h +0 -0
  64. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/ostreamwrapper.h +0 -0
  65. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/pointer.h +0 -0
  66. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/prettywriter.h +0 -0
  67. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/rapidjson.h +0 -0
  68. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/reader.h +0 -0
  69. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/schema.h +0 -0
  70. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/stream.h +0 -0
  71. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/stringbuffer.h +0 -0
  72. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/uri.h +0 -0
  73. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/include/rapidjson/writer.h +0 -0
  74. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/license.txt +0 -0
  75. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson/readme.md +0 -0
  76. {python-rapidjson-1.19 → python_rapidjson-1.20}/rapidjson_exact_version.txt +0 -0
  77. {python-rapidjson-1.19 → python_rapidjson-1.20}/requirements-test.txt +0 -0
  78. {python-rapidjson-1.19 → python_rapidjson-1.20}/requirements.txt +0 -0
  79. {python-rapidjson-1.19 → python_rapidjson-1.20}/setup.cfg +0 -0
  80. {python-rapidjson-1.19 → python_rapidjson-1.20}/setup.py +0 -0
  81. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/conftest.py +0 -0
  82. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_circular.py +0 -0
  83. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_dict_subclass.py +0 -0
  84. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_enum.py +0 -0
  85. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_float.py +0 -0
  86. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_memory_leaks.py +0 -0
  87. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_params.py +0 -0
  88. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_pass1.py +0 -0
  89. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_pass2.py +0 -0
  90. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_pass3.py +0 -0
  91. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_rawjson.py +0 -0
  92. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_refs_count.py +0 -0
  93. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_streams.py +0 -0
  94. {python-rapidjson-1.19 → python_rapidjson-1.20}/tests/test_unicode.py +0 -0
  95. {python-rapidjson-1.19 → python_rapidjson-1.20}/tox.ini +0 -0
@@ -1,6 +1,20 @@
1
1
  Changes
2
2
  -------
3
3
 
4
+ 1.20 (2024-08-05)
5
+ ~~~~~~~~~~~~~~~~~
6
+
7
+ * Rectify type hints if ``loads()`` and ``Decoder.__call__()`` (`issue #214`__)
8
+
9
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/214
10
+
11
+ * Ensure ``Validator`` receives valid UTF-8 ``bytes``/``bytearray`` arguments
12
+
13
+ * Generate wheels on PyPI using Python 3.13.0rc1 release, thanks to cibuildwheel `2.20.0`__
14
+
15
+ __ https://cibuildwheel.pypa.io/en/stable/changelog/#v2200
16
+
17
+
4
18
  1.19 (2024-07-28)
5
19
  ~~~~~~~~~~~~~~~~~
6
20
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-rapidjson
3
- Version: 1.19
3
+ Version: 1.20
4
4
  Summary: Python wrapper around rapidjson
5
5
  Home-page: https://github.com/python-rapidjson/python-rapidjson
6
6
  Author: Ken Robbins
@@ -155,6 +155,20 @@ __ https://python-rapidjson.readthedocs.io/en/latest/quickstart.html#incompatibi
155
155
  Changes
156
156
  -------
157
157
 
158
+ 1.20 (2024-08-05)
159
+ ~~~~~~~~~~~~~~~~~
160
+
161
+ * Rectify type hints if ``loads()`` and ``Decoder.__call__()`` (`issue #214`__)
162
+
163
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/214
164
+
165
+ * Ensure ``Validator`` receives valid UTF-8 ``bytes``/``bytearray`` arguments
166
+
167
+ * Generate wheels on PyPI using Python 3.13.0rc1 release, thanks to cibuildwheel `2.20.0`__
168
+
169
+ __ https://cibuildwheel.pypa.io/en/stable/changelog/#v2200
170
+
171
+
158
172
  1.19 (2024-07-28)
159
173
  ~~~~~~~~~~~~~~~~~
160
174
 
@@ -1,6 +1,20 @@
1
1
  Changes
2
2
  -------
3
3
 
4
+ 1.20 (2024-08-05)
5
+ ~~~~~~~~~~~~~~~~~
6
+
7
+ * Rectify type hints if ``loads()`` and ``Decoder.__call__()`` (`issue #214`__)
8
+
9
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/214
10
+
11
+ * Ensure ``Validator`` receives valid UTF-8 ``bytes``/``bytearray`` arguments
12
+
13
+ * Generate wheels on PyPI using Python 3.13.0rc1 release, thanks to cibuildwheel `2.20.0`__
14
+
15
+ __ https://cibuildwheel.pypa.io/en/stable/changelog/#v2200
16
+
17
+
4
18
  1.19 (2024-07-28)
5
19
  ~~~~~~~~~~~~~~~~~
6
20
 
@@ -2,7 +2,7 @@
2
2
  .. :Project: python-rapidjson -- Validator class documentation
3
3
  .. :Author: Lele Gaifax <lele@metapensiero.it>
4
4
  .. :License: MIT License
5
- .. :Copyright: © 2017, 2018, 2019, 2020 Lele Gaifax
5
+ .. :Copyright: © 2017, 2018, 2019, 2020, 2024 Lele Gaifax
6
6
  ..
7
7
 
8
8
  =================
@@ -18,7 +18,7 @@
18
18
  .. class:: Validator(json_schema)
19
19
 
20
20
  :param json_schema: the `JSON schema`__, specified as a ``str`` instance or an *UTF-8*
21
- ``bytes`` instance
21
+ :class:`bytes`/:class:`bytearray` instance
22
22
  :raises JSONDecodeError: if `json_schema` is not a valid ``JSON`` value
23
23
 
24
24
  __ http://json-schema.org/documentation.html
@@ -26,7 +26,7 @@
26
26
  .. method:: __call__(json)
27
27
 
28
28
  :param json: the ``JSON`` value, specified as a ``str`` instance or an *UTF-8*
29
- ``bytes`` instance, that will be validated
29
+ :class:`bytes`/:class:`bytearray` instance, that will be validated
30
30
  :raises JSONDecodeError: if `json` is not a valid ``JSON`` value
31
31
 
32
32
  The given `json` value will be validated accordingly to the *schema*: a
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-rapidjson
3
- Version: 1.19
3
+ Version: 1.20
4
4
  Summary: Python wrapper around rapidjson
5
5
  Home-page: https://github.com/python-rapidjson/python-rapidjson
6
6
  Author: Ken Robbins
@@ -155,6 +155,20 @@ __ https://python-rapidjson.readthedocs.io/en/latest/quickstart.html#incompatibi
155
155
  Changes
156
156
  -------
157
157
 
158
+ 1.20 (2024-08-05)
159
+ ~~~~~~~~~~~~~~~~~
160
+
161
+ * Rectify type hints if ``loads()`` and ``Decoder.__call__()`` (`issue #214`__)
162
+
163
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/214
164
+
165
+ * Ensure ``Validator`` receives valid UTF-8 ``bytes``/``bytearray`` arguments
166
+
167
+ * Generate wheels on PyPI using Python 3.13.0rc1 release, thanks to cibuildwheel `2.20.0`__
168
+
169
+ __ https://cibuildwheel.pypa.io/en/stable/changelog/#v2200
170
+
171
+
158
172
  1.19 (2024-07-28)
159
173
  ~~~~~~~~~~~~~~~~~
160
174
 
@@ -2156,8 +2156,9 @@ decoder_call(PyObject* self, PyObject* args, PyObject* kwargs)
2156
2156
  jsonStr = NULL;
2157
2157
  jsonStrLen = 0;
2158
2158
  } else {
2159
- PyErr_SetString(PyExc_TypeError,
2160
- "Expected string or UTF-8 encoded bytes or bytearray");
2159
+ PyErr_SetString(
2160
+ PyExc_TypeError,
2161
+ "Expected string or UTF-8 encoded bytes or bytearray or a file-like object");
2161
2162
  return NULL;
2162
2163
  }
2163
2164
 
@@ -3725,17 +3726,24 @@ static PyObject* validator_call(PyObject* self, PyObject* args, PyObject* kwargs
3725
3726
  return NULL;
3726
3727
 
3727
3728
  const char* jsonStr;
3729
+ PyObject* asUnicode = NULL;
3728
3730
 
3729
- if (PyBytes_Check(jsonObject)) {
3730
- jsonStr = PyBytes_AsString(jsonObject);
3731
- if (jsonStr == NULL)
3732
- return NULL;
3733
- } else if (PyUnicode_Check(jsonObject)) {
3731
+ if (PyUnicode_Check(jsonObject)) {
3734
3732
  jsonStr = PyUnicode_AsUTF8(jsonObject);
3735
3733
  if (jsonStr == NULL)
3736
3734
  return NULL;
3735
+ } else if (PyBytes_Check(jsonObject) || PyByteArray_Check(jsonObject)) {
3736
+ asUnicode = PyUnicode_FromEncodedObject(jsonObject, "utf-8", NULL);
3737
+ if (asUnicode == NULL)
3738
+ return NULL;
3739
+ jsonStr = PyUnicode_AsUTF8(asUnicode);
3740
+ if (jsonStr == NULL) {
3741
+ Py_DECREF(asUnicode);
3742
+ return NULL;
3743
+ }
3737
3744
  } else {
3738
- PyErr_SetString(PyExc_TypeError, "Expected string or UTF-8 encoded bytes");
3745
+ PyErr_SetString(PyExc_TypeError,
3746
+ "Expected string or UTF-8 encoded bytes or bytearray");
3739
3747
  return NULL;
3740
3748
  }
3741
3749
 
@@ -3747,6 +3755,8 @@ static PyObject* validator_call(PyObject* self, PyObject* args, PyObject* kwargs
3747
3755
  Py_END_ALLOW_THREADS
3748
3756
 
3749
3757
  if (error) {
3758
+ if (asUnicode != NULL)
3759
+ Py_DECREF(asUnicode);
3750
3760
  PyErr_SetString(decode_error, "Invalid JSON");
3751
3761
  return NULL;
3752
3762
  }
@@ -3758,6 +3768,9 @@ static PyObject* validator_call(PyObject* self, PyObject* args, PyObject* kwargs
3758
3768
  accept = d.Accept(validator);
3759
3769
  Py_END_ALLOW_THREADS
3760
3770
 
3771
+ if (asUnicode != NULL)
3772
+ Py_DECREF(asUnicode);
3773
+
3761
3774
  if (!accept) {
3762
3775
  StringBuffer sptr;
3763
3776
  StringBuffer dptr;
@@ -3771,7 +3784,9 @@ static PyObject* validator_call(PyObject* self, PyObject* args, PyObject* kwargs
3771
3784
  sptr.GetString(), dptr.GetString());
3772
3785
  PyErr_SetObject(validation_error, error);
3773
3786
 
3774
- Py_XDECREF(error);
3787
+ if (error != NULL)
3788
+ Py_DECREF(error);
3789
+
3775
3790
  sptr.Clear();
3776
3791
  dptr.Clear();
3777
3792
 
@@ -3798,17 +3813,24 @@ static PyObject* validator_new(PyTypeObject* type, PyObject* args, PyObject* kwa
3798
3813
  return NULL;
3799
3814
 
3800
3815
  const char* jsonStr;
3816
+ PyObject* asUnicode = NULL;
3801
3817
 
3802
- if (PyBytes_Check(jsonObject)) {
3803
- jsonStr = PyBytes_AsString(jsonObject);
3804
- if (jsonStr == NULL)
3805
- return NULL;
3806
- } else if (PyUnicode_Check(jsonObject)) {
3818
+ if (PyUnicode_Check(jsonObject)) {
3807
3819
  jsonStr = PyUnicode_AsUTF8(jsonObject);
3808
3820
  if (jsonStr == NULL)
3809
3821
  return NULL;
3822
+ } else if (PyBytes_Check(jsonObject) || PyByteArray_Check(jsonObject)) {
3823
+ asUnicode = PyUnicode_FromEncodedObject(jsonObject, "utf-8", NULL);
3824
+ if (asUnicode == NULL)
3825
+ return NULL;
3826
+ jsonStr = PyUnicode_AsUTF8(asUnicode);
3827
+ if (jsonStr == NULL) {
3828
+ Py_DECREF(asUnicode);
3829
+ return NULL;
3830
+ }
3810
3831
  } else {
3811
- PyErr_SetString(PyExc_TypeError, "Expected string or UTF-8 encoded bytes");
3832
+ PyErr_SetString(PyExc_TypeError,
3833
+ "Expected string or UTF-8 encoded bytes or bytearray");
3812
3834
  return NULL;
3813
3835
  }
3814
3836
 
@@ -3819,6 +3841,9 @@ static PyObject* validator_new(PyTypeObject* type, PyObject* args, PyObject* kwa
3819
3841
  error = d.Parse(jsonStr).HasParseError();
3820
3842
  Py_END_ALLOW_THREADS
3821
3843
 
3844
+ if (asUnicode != NULL)
3845
+ Py_DECREF(asUnicode);
3846
+
3822
3847
  if (error) {
3823
3848
  PyErr_SetString(decode_error, "Invalid JSON");
3824
3849
  return NULL;
@@ -3,7 +3,7 @@
3
3
  # :Author: John Anderson <sontek@gmail.com>
4
4
  # :License: MIT License
5
5
  # :Copyright: © 2015 John Anderson
6
- # :Copyright: © 2016, 2017, 2018, 2019, 2020, 2021 Lele Gaifax
6
+ # :Copyright: © 2016, 2017, 2018, 2019, 2020, 2021, 2024 Lele Gaifax
7
7
  #
8
8
 
9
9
  import random
@@ -182,6 +182,19 @@ def test_decode_error(loads):
182
182
  pytest.raises(rj.JSONDecodeError, loads, '{')
183
183
 
184
184
 
185
+ def test_decode_bytes_and_bytearray():
186
+ s = 'FòBàr'
187
+ j = f'"{s}"'
188
+ utf32 = j.encode('utf-32')
189
+ for loader in (rj.loads, rj.Decoder()):
190
+ pytest.raises(UnicodeDecodeError, loader, utf32)
191
+
192
+ utf8 = j.encode('utf-8')
193
+ for loader in (rj.loads, rj.Decoder()):
194
+ for data in (utf8, bytearray(utf8)):
195
+ assert loader(data) == s
196
+
197
+
185
198
  def test_shared_keys(loads):
186
199
  res = loads('[{"key": "value1"}, {"key": "value2"}]')
187
200
  key1, = res[0].keys()
@@ -2,7 +2,7 @@
2
2
  # :Project: python-rapidjson -- Validator class tests
3
3
  # :Author: Lele Gaifax <lele@metapensiero.it>
4
4
  # :License: MIT License
5
- # :Copyright: © 2017, 2019, 2020 Lele Gaifax
5
+ # :Copyright: © 2017, 2019, 2020, 2024 Lele Gaifax
6
6
  #
7
7
 
8
8
  import pytest
@@ -26,8 +26,10 @@ def test_invalid_json():
26
26
  ('{ "type": ["number", "string"] }', '"Life, the universe, and everything"'),
27
27
  ))
28
28
  def test_valid(schema, json):
29
- validate = rj.Validator(schema)
30
- validate(json)
29
+ for s in (schema, schema.encode('utf-8'), bytearray(schema.encode('utf-8'))):
30
+ for j in (json, json.encode('utf-8'), bytearray(json.encode('utf-8'))):
31
+ validate = rj.Validator(s)
32
+ validate(j)
31
33
 
32
34
 
33
35
  @pytest.mark.parametrize('schema,json,details', (
@@ -148,7 +148,7 @@ def load(
148
148
  allow_nan: t.Optional[bool] = True,
149
149
  ) -> t.Any: ...
150
150
  def loads(
151
- string: str,
151
+ string: t.Union[str, bytes, bytearray],
152
152
  *,
153
153
  object_hook: t.Optional[t.Callable[[t.Dict[str, t.Any]], t.Any]] = None,
154
154
  number_mode: t.Optional[_NumberMode] = NM_NAN,
@@ -179,7 +179,7 @@ class Decoder:
179
179
  ) -> None: ...
180
180
  def __call__(
181
181
  self,
182
- json: t.Union[str, bytes, t.IO],
182
+ json: t.Union[str, bytes, bytearray, t.IO],
183
183
  chunk_size: t.Optional[int] = 65536,
184
184
  ) -> t.Any: ...
185
185
 
@@ -228,5 +228,5 @@ class RawJSON:
228
228
 
229
229
  @t.final
230
230
  class Validator:
231
- def __init__(self, json_schema: t.Union[str, bytes]) -> None: ...
232
- def __call__(self, json: t.Union[str, bytes]) -> None: ...
231
+ def __init__(self, json_schema: t.Union[str, bytes, bytearray]) -> None: ...
232
+ def __call__(self, json: t.Union[str, bytes, bytearray]) -> None: ...
@@ -0,0 +1 @@
1
+ 1.20
@@ -1 +0,0 @@
1
- 1.19
File without changes
File without changes