Skip to content

Commit 1a8011b

Browse files
Michael Howitzmauritsvanrees
andauthored
Allow to use the package with Python 3.12. (#248)
* Additional conditional code branch reduced coverage for Py39. * Fix badge. * Omit `pip list` to make Windows Py 3.12 happy. Co-authored-by: Maurits van Rees <[email protected]>
1 parent 9ada64e commit 1a8011b

File tree

9 files changed

+25
-11
lines changed

9 files changed

+25
-11
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- ["3.9", "py39"]
2828
- ["3.10", "py310"]
2929
- ["3.11", "py311"]
30+
- ["3.12.0-alpha.5", "py312"]
3031
- ["3.9", "docs"]
3132
- ["3.9", "coverage"]
3233
- ["3.9", "py39-datetime"]

.meta.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ with-pypy = false
99
with-docs = true
1010
with-sphinx-doctests = true
1111
with-windows = true
12-
with-future-python = false
12+
with-future-python = true
1313
with-macos = false
1414

1515
[tox]
@@ -28,7 +28,6 @@ testenv-setenv = [
2828
]
2929
testenv-commands = [
3030
"python -V",
31-
"pip list",
3231
"pytest --cov=src --cov=tests --cov-report= {posargs}",
3332
]
3433
testenv-additional = [
@@ -57,7 +56,7 @@ coverage-setenv = [
5756
]
5857

5958
[coverage]
60-
fail-under = 98.5
59+
fail-under = 98.4
6160

6261
[isort]
6362
additional-sources = "{toxinidir}/tests"

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Backwards incompatible changes
99

1010
- Drop support for Python 3.6.
1111

12+
Features
13+
++++++++
14+
15+
- Allow to use the package with Python 3.12 -- Caution: No security audit has
16+
been done so far.
1217

1318

1419
6.0 (2022-11-03)

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.. image:: https://api.travis-ci.com/zopefoundation/RestrictedPython.svg?branch=master
2-
:target: https://travis-ci.com/zopefoundation/RestrictedPython
1+
.. image:: https://github.com/zopefoundation/RestrictedPython/actions/workflows/tests.yml/badge.svg
2+
:target: https://github.com/zopefoundation/RestrictedPython/actions/workflows/tests.yml
33

44
.. image:: https://coveralls.io/repos/github/zopefoundation/RestrictedPython/badge.svg?branch=master
55
:target: https://coveralls.io/github/zopefoundation/RestrictedPython?branch=master
@@ -83,5 +83,5 @@ Contributing to RestrictedPython
8383
--------------------------------
8484

8585
If you want to help maintain RestrictedPython and contribute, please refer to
86-
the documentation `Contributing page
86+
the documentation `Contributing page
8787
<https://restrictedpython.readthedocs.io/en/latest/contributing/index.html>`_.

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RestrictedPython is not a sandbox system or a secured environment, but it helps
1515
Supported Python versions
1616
=========================
1717

18-
RestrictedPython supports CPython 2.7, 3.5, 3.6, 3.7 and 3.8.
18+
RestrictedPython supports CPython 3.7 up to 3.12.
1919
It does _not_ support PyPy or other alternative Python implementations.
2020

2121
Contents

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def read(*rnames):
6767
package_dir={'': 'src'},
6868
install_requires=[
6969
],
70-
python_requires=">=3.7, <3.12",
70+
python_requires=">=3.7, <3.13",
7171
tests_require=tests_require,
7272
extras_require={
7373
'test': tests_require,

src/RestrictedPython/_compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
IS_PY38_OR_GREATER = _version.major == 3 and _version.minor >= 8
77
IS_PY310_OR_GREATER = _version.major == 3 and _version.minor >= 10
88
IS_PY311_OR_GREATER = _version.major == 3 and _version.minor >= 11
9+
IS_PY312_OR_GREATER = _version.major == 3 and _version.minor >= 12
910

1011
IS_CPYTHON = platform.python_implementation() == 'CPython'

tests/test_compile.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from RestrictedPython import compile_restricted_single
1111
from RestrictedPython._compat import IS_PY38_OR_GREATER
1212
from RestrictedPython._compat import IS_PY310_OR_GREATER
13+
from RestrictedPython._compat import IS_PY312_OR_GREATER
1314
from tests.helper import restricted_eval
1415

1516

@@ -102,7 +103,13 @@ def test_compile__compile_restricted_exec__5():
102103
assert result.code is None
103104
assert result.warnings == []
104105
assert result.used_names == {}
105-
assert result.errors == ('source code string cannot contain null bytes',)
106+
if IS_PY312_OR_GREATER:
107+
assert result.errors == (
108+
'Line None: SyntaxError: source code string cannot contain null'
109+
' bytes at statement: None',)
110+
else:
111+
assert result.errors == (
112+
'source code string cannot contain null bytes',)
106113

107114

108115
EXEC_STATEMENT = """\

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ envlist =
99
py39
1010
py310
1111
py311
12+
py312
1213
docs
1314
coverage
1415
py39-datetime
1516
combined-coverage
1617

1718
[testenv]
1819
usedevelop = true
20+
pip_pre = py312: true
1921
deps =
2022
datetime: DateTime
2123
-cconstraints.txt
@@ -25,7 +27,6 @@ setenv =
2527
COVERAGE_FILE=.coverage.{envname}
2628
commands =
2729
python -V
28-
pip list
2930
pytest --cov=src --cov=tests --cov-report= {posargs}
3031
sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
3132
extras =
@@ -98,7 +99,7 @@ commands =
9899
pytest --cov=src --cov=tests --cov-report= {posargs}
99100
coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
100101
coverage html --ignore-errors
101-
coverage report --ignore-errors --show-missing --fail-under=98.5
102+
coverage report --ignore-errors --show-missing --fail-under=98.4
102103

103104
[coverage:run]
104105
branch = True

0 commit comments

Comments
 (0)