Skip to content

Commit 2d62ff0

Browse files
committed
Merge branch 'master' into yggdrasil
Fix bug in parsing of bytes messages in validation when determining if a python object should be parsed or interpreted directly Fix bugs in ObjWavefront handling of colors
2 parents b78fa24 + 855a4f9 commit 2d62ff0

32 files changed

+912
-276
lines changed

.bumpversion.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
# :Project: python-rapidjson — Configuration for bump-my-version
3+
# :Created: lun 4 nov 2024, 08:25:29
4+
# :Author: Lele Gaifax <lele@metapensiero.it>
5+
# :License: MIT License
6+
# :Copyright: © 2024 Lele Gaifax
7+
#
8+
9+
[tool.bumpversion]
10+
current_version = "1.21"
11+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)"
12+
serialize = [
13+
"{major}.{minor}",
14+
]
15+
search = "{current_version}"
16+
replace = "{new_version}"
17+
regex = false
18+
ignore_missing_version = false
19+
ignore_missing_files = false
20+
tag = false
21+
sign_tags = false
22+
tag_name = "v{new_version}"
23+
tag_message = "Bump version: {current_version} → {new_version}"
24+
allow_dirty = false
25+
commit = false
26+
message = "Bump version: {current_version} → {new_version}"
27+
commit_args = ""
28+
29+
[[tool.bumpversion.files]]
30+
filename = "setup.py"
31+
search = "VERSION = '{current_version}'"
32+
replace = "VERSION = '{new_version}'"

.github/workflows/main.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# :Author: Martin Thoma <info@martin-thoma.de>
55
# :License: MIT License
66
# :Copyright: © 2020 Martin Thoma
7-
# :Copyright: © 2020, 2021, 2022, 2023, 2024 Lele Gaifax
7+
# :Copyright: © 2020, 2021, 2022, 2023, 2024, 2025 Lele Gaifax
88
#
99

1010
# For more information see:
@@ -52,6 +52,10 @@ jobs:
5252
run: |
5353
make -C docs doctest -e PYTHON=$(which python3)
5454
55+
- name: Typing stub tests
56+
run: |
57+
stubtest rapidjson
58+
5559
debug-tests:
5660
name: Memory leak tests, on current debug build Python
5761
runs-on: ubuntu-latest
@@ -65,7 +69,7 @@ jobs:
6569
with:
6670
submodules: recursive
6771

68-
- uses: deadsnakes/action@v3.1.0
72+
- uses: deadsnakes/action@v3.2.0
6973
with:
7074
python-version: ${{ matrix.python-version }}
7175
debug: true
@@ -84,15 +88,15 @@ jobs:
8488
strategy:
8589
matrix:
8690
os:
87-
- ubuntu-22.04
88-
- macos-12
89-
- windows-2019
91+
- ubuntu-24.04
92+
- macos-13
93+
- windows-2025
9094
arch:
9195
- auto
9296
include:
93-
- os: ubuntu-22.04
97+
- os: ubuntu-24.04
9498
arch: aarch64
95-
# - os: ubuntu-22.04
99+
# - os: ubuntu-24.04
96100
# arch: ppc64le
97101
- os: macos-14
98102
arch: arm64
@@ -114,13 +118,16 @@ jobs:
114118
name: Set up QEMU
115119

116120
- name: Build wheels
117-
uses: pypa/cibuildwheel@v2.16.5
121+
uses: pypa/cibuildwheel@v3.1.3
118122
env:
119123
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
120124
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
121125
CIBW_TEST_REQUIRES: "pytest pytest-benchmark pytz"
122126
CIBW_TEST_COMMAND: "pytest -sv {project}/tests"
123-
CIBW_SKIP: "cp2* cp33* cp34* cp35* cp36* pp* cp310-manylinux_i686 cp311-manylinux_i686 cp312-manylinux_i686 *-musllinux_*"
127+
CIBW_SKIP: "cp2* cp33* cp34* cp35* cp36* cp38* pp* cp310-manylinux_i686 cp311-manylinux_i686 cp312-manylinux_i686 *-musllinux_*"
128+
# Skip tests on emulated hardware, take too long or not supported
129+
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le} *-macosx_*:arm64"
130+
CIBW_ENABLE: cpython-prerelease
124131
CIBW_ENVIRONMENT: "PIP_ONLY_BINARY=numpy"
125132
# CIBW_BEFORE_BUILD: python -m pip install oldest-supported-numpy
126133
# CIBW_PRERELEASE_PYTHONS: True
@@ -136,8 +143,12 @@ jobs:
136143
# needs: build_wheels
137144
# runs-on: ubuntu-latest
138145

139-
# # Upload to PyPI on every tag starting with 'v'
140-
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
146+
# Upload to PyPI on every tag starting with 'v'
147+
# FIXME: for some reason, the job is skipped, although the configuration is
148+
# almost identical to the one I use on pglast... let's try to temporarily
149+
# remove the condition
150+
# langmm: Disabled until name change for fork
151+
## if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
141152

142153
# steps:
143154
# - uses: actions/download-artifact@v4

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,10 @@ target/
6464
# Emacs stuff
6565
/.emacs.desktop.lock
6666
/emacs.desktop
67-
*~
67+
*~
68+
69+
# Virtualenv
70+
.venv/
71+
72+
# Git Worktree
73+
.wt/

.readthedocs.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
# :Project: python-rapidjson — Configuration for Read the Docs
3+
# :Created: sab 18 mag 2024, 15:59:36
4+
# :Author: Lele Gaifax <lele@metapensiero.it>
5+
# :License: MIT License
6+
# :Copyright: © 2024 Lele Gaifax
7+
#
8+
9+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
10+
11+
version: 2
12+
13+
submodules:
14+
include: all
15+
16+
build:
17+
os: ubuntu-22.04
18+
tools:
19+
python: "3.11"
20+
21+
python:
22+
install:
23+
- requirements: requirements.txt
24+
- method: pip
25+
path: .
26+
27+
sphinx:
28+
configuration: docs/conf.py

CHANGES.rst

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,84 @@
11
Changes
22
-------
33

4+
1.21 (2025-07-10)
5+
~~~~~~~~~~~~~~~~~
6+
7+
* Use `current master`__ version of rapidjson, thanks to Kyle Gottfried (although I didn't
8+
merge his `PR #224`__)
9+
10+
__ https://github.com/Tencent/rapidjson/compare/ab1842a2dae061284c0a62dca1cc6d5e7e37e346..24b5e7a8b27f42fa16b96fc70aade9106cf7102f
11+
__ https://github.com/python-rapidjson/python-rapidjson/pull/224
12+
13+
* Recompute comparison table with latest versions of other libraries, using Python 3.13
14+
15+
* Typing stubs: specify default value for ``stream`` argument of ``Encoder.__call__()``
16+
(`issue #215`__)
17+
18+
__ https://github.com/python-rapidjson/python-rapidjson/issues/215
19+
20+
* Use more recent OS images on GH Actions to test and build wheels
21+
22+
23+
1.20 (2024-08-05)
24+
~~~~~~~~~~~~~~~~~
25+
26+
* Rectify type hints of ``loads()`` and ``Decoder.__call__()`` (`issue #214`__)
27+
28+
__ https://github.com/python-rapidjson/python-rapidjson/issues/214
29+
30+
* Ensure ``Validator`` receives valid UTF-8 ``bytes``/``bytearray`` arguments
31+
32+
* Generate wheels on PyPI using Python 3.13.0rc1 release, thanks to cibuildwheel `2.20.0`__
33+
34+
__ https://cibuildwheel.pypa.io/en/stable/changelog/#v2200
35+
36+
37+
1.19 (2024-07-28)
38+
~~~~~~~~~~~~~~~~~
39+
40+
* Properly dump subclasses of ``float`` with custom ``__repr__()`` method ( `issue #213`__)
41+
42+
__ https://github.com/python-rapidjson/python-rapidjson/issues/213
43+
44+
45+
1.18 (2024-06-29)
46+
~~~~~~~~~~~~~~~~~
47+
48+
* Expose PEP-484 typing stubs, thanks to Rodion Kosianenko and GoodWasHere (`PR #204`__)
49+
50+
__ https://github.com/python-rapidjson/python-rapidjson/pull/204
51+
52+
53+
1.17 (2024-05-18)
54+
~~~~~~~~~~~~~~~~~
55+
56+
* Use `current master`__ version of rapidjson
57+
58+
__ https://github.com/Tencent/rapidjson/compare/5e17dbed34eef33af8f3e734820b5dc547a2a3aa...ab1842a2dae061284c0a62dca1cc6d5e7e37e346
59+
60+
* Generate wheels on PyPI using Python 3.13b1 release, thanks to cibuildwheel `2.18.0`__
61+
62+
__ https://cibuildwheel.pypa.io/en/stable/changelog/#v2180
63+
64+
65+
1.16 (2024-02-28)
66+
~~~~~~~~~~~~~~~~~
67+
68+
* Produce Python 3.8 wheels again, I deactivated it too eagerly, it's in *security fixes
69+
only* mode, not yet reached its `end-of-life` state
70+
71+
72+
1.15 (2024-02-28)
73+
~~~~~~~~~~~~~~~~~
74+
75+
* Honor the `recursion limit`__ also at parse time, to avoid attacks as described by
76+
`CVE-2024-27454`__
77+
78+
__ https://docs.python.org/3.12/library/sys.html#sys.setrecursionlimit
79+
__ https://monicz.dev/CVE-2024-27454
80+
81+
482
1.14 (2023-12-14)
583
~~~~~~~~~~~~~~~~~
684

@@ -30,7 +108,7 @@ Changes
30108

31109
* Use `current master`__ version of rapidjson
32110

33-
__ https://github.com/Tencent/rapidjson/compare/083f359f5c36198accc2b9360ce1e32a333231d9...5e17dbed34eef33af8f3e734820b5dc547a2a3aa9
111+
__ https://github.com/Tencent/rapidjson/compare/083f359f5c36198accc2b9360ce1e32a333231d9...5e17dbed34eef33af8f3e734820b5dc547a2a3aa
34112

35113
* Use cibuildwheel `2.15.0`__
36114

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python-rapidjson is licensed under the MIT license.
33
The MIT License (MIT)
44

55
Copyright (c) 2015, 2016, 2017 Ken Robbins
6+
Copyright (c) 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Lele Gaifax
67

78
Permission is hereby granted, free of charge, to any person obtaining a copy
89
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include .dir-locals.el
22
include LICENSE MANIFEST.in *.cfg *.ini *.py *.rst *.txt
33
include python-rapidjson/*.cpp python-rapidjson/*.h
44
include benchmarks/*.py tests/*.py
5+
include typings/*.pyi
56

67
exclude .github .gitmodules
78

Makefile.release

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
# :Project: python-rapidjson -- Release specific targets
33
# :Author: Lele Gaifax <lele@metapensiero.it>
44
# :License: MIT License
5-
# :Copyright: © 2017, 2019, 2020 Lele Gaifax
5+
# :Copyright: © 2017, 2019, 2020, 2024 Lele Gaifax
66
#
77

8-
BUMPER = $(VENVDIR)/bin/bump_version -s simple2
9-
VERSION_TXT := version.txt
10-
VERSION = $(shell cat $(VERSION_TXT))
11-
PACKAGE_NAME = $(shell $(PYTHON) setup.py --name)
8+
BUMPER = $(VENVDIR)/bin/bump-my-version bump
9+
VERSION = $(shell bump-my-version show current_version 2>/dev/null)
10+
PACKAGE_NAME = python_rapidjson
1211
TWINE := $(BINDIR)twine
1312

1413
help::
@@ -30,7 +29,7 @@ help::
3029

3130
.PHONY: release
3231
release: assert-master-branch assert-clean-tree
33-
$(BUMPER) $(VERSION_TXT)
32+
$(BUMPER) minor
3433
@echo ">>>"
3534
@echo ">>> Do your duties (update CHANGES.rst for example), then"
3635
@echo ">>> execute “make tag-release”."

README.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.. :Author: Ken Robbins <ken@kenrobbins.com>
44
.. :License: MIT License
55
.. :Copyright: © 2015 Ken Robbins
6-
.. :Copyright: © 2016, 2017, 2018, 2020, 2022 Lele Gaifax
6+
.. :Copyright: © 2016, 2017, 2018, 2020, 2022, 2024, 2025 Lele Gaifax
77
..
88
99
==================
@@ -75,6 +75,26 @@ Basic usage looks like this:
7575
Chunk: b'":"ba'
7676
Chunk: b'z"}'
7777
78+
Most functionalities are exposed both as *functions* and as *classes*.
79+
80+
The following uses a *relaxed syntax* ``Decoder`` instance, that handles JSONC__ and
81+
*trailing commas*:
82+
83+
__ https://jsonc.org/
84+
85+
.. code-block:: python
86+
87+
>>> from rapidjson import Decoder
88+
>>> from rapidjson import PM_COMMENTS, PM_TRAILING_COMMAS
89+
>>> decoder = Decoder(parse_mode=PM_COMMENTS | PM_TRAILING_COMMAS)
90+
>>> decoder('''
91+
... {
92+
... "bar": /* Block comment */ "baz",
93+
... "foo":100, // Trailing comma and comment
94+
... }
95+
... ''')
96+
{'bar': 'baz', 'foo': 100}
97+
7898
7999
Development
80100
-----------
@@ -108,7 +128,7 @@ Performance
108128
``python-rapidjson`` tries to be as performant as possible while staying
109129
compatible with the ``json`` module.
110130

111-
See the `this section`__ in the documentation for a comparison with other JSON libraries.
131+
See `this section`__ in the documentation for a comparison with other JSON libraries.
112132

113133
__ https://python-rapidjson.readthedocs.io/en/latest/benchmarks.html
114134

benchmarks/conftest.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# :Project: python-rapidjson -- Benchmarks specific pytest configuration
33
# :Author: Lele Gaifax <lele@metapensiero.it>
44
# :License: MIT License
5-
# :Copyright: © 2016, 2017, 2018, 2020 Lele Gaifax
5+
# :Copyright: © 2016, 2017, 2018, 2020, 2024 Lele Gaifax
66
#
77

88
from collections import namedtuple
@@ -56,6 +56,32 @@ def pytest_addoption(parser):
5656
rj.Encoder(number_mode=rj.NM_NATIVE),
5757
rj.Decoder(number_mode=rj.NM_NATIVE)))
5858

59+
60+
61+
class DecoderPython(rj.Decoder):
62+
def end_array(self, a):
63+
return a
64+
65+
def start_object(self):
66+
return {}
67+
68+
def end_object(self, d):
69+
return d
70+
71+
def string(self, s):
72+
return s
73+
74+
75+
class EncoderPython(rj.Encoder):
76+
def default(self, obj):
77+
return repr(obj)
78+
79+
80+
contenders.append(Contender('rapidjson_p',
81+
EncoderPython(),
82+
DecoderPython()))
83+
84+
5985
numbers_contenders = [
6086
Contender('Wide numbers', rj.dumps, rj.loads),
6187
Contender('Native numbers',
@@ -147,7 +173,9 @@ def pytest_generate_tests(metafunc):
147173
if metafunc.config.option.compare_other_engines:
148174
metafunc.parametrize('contender', contenders, ids=attrgetter('name'))
149175
else:
150-
metafunc.parametrize('contender', contenders[:1], ids=attrgetter('name'))
176+
metafunc.parametrize('contender', [c for c in contenders
177+
if c.name.startswith('rapidjson')],
178+
ids=attrgetter('name'))
151179

152180
if 'datetimes_loads_contender' in metafunc.fixturenames:
153181
metafunc.parametrize('datetimes_loads_contender',

0 commit comments

Comments
 (0)