Skip to content

Commit bafb976

Browse files
loechelicemac
andauthored
Add support for Python 3.12 (#263)
Co-authored-by: Michael Howitz <[email protected]>
1 parent b5d8e7f commit bafb976

File tree

8 files changed

+34
-32
lines changed

8 files changed

+34
-32
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
- ["3.10", "py310"]
2929
- ["3.11", "py311"]
3030
- ["3.12", "py312"]
31-
- ["3.13.0-alpha - 3.13.0", "py313"]
3231
- ["3.9", "docs"]
3332
- ["3.9", "coverage"]
3433
- ["3.9", "py39-datetime"]

.meta.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ testenv-additional = [
4747
" coverage combine",
4848
" coverage html",
4949
" coverage report -m --fail-under=100",
50-
"depends = py37,py38,py39,py39-datetime,py310,py311,py312coverage",
50+
"depends = py37,py38,py39,py39-datetime,py310,py311,py312,coverage",
5151
]
5252
coverage-basepython = "python3.8"
5353
coverage-command = "pytest --cov=src --cov=tests --cov-report= {posargs}"

CHANGES.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Backwards incompatible changes
1212
Features
1313
++++++++
1414

15-
- Allow to use the package with Python 3.12 and 3.13 -- Caution: No security
16-
audit has been done so far.
15+
- Officially support Python 3.12.
1716

1817
Fixes
1918
+++++
@@ -23,8 +22,7 @@ Fixes
2322
- Forbid using some attributes providing access to restricted Python internals.
2423
(CVE-2023-37271)
2524

26-
- Fix information disclosure problems through
27-
Python's "format" functionality
25+
- Fix information disclosure problems through Python's "format" functionality
2826
(``format`` and ``format_map`` methods on ``str`` and its instances,
2927
``string.Formatter``). (CVE-2023-41039)
3028

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@
4747

4848
# General information about the project.
4949
project = 'RestrictedPython'
50-
copyright = '2017-2022, Zope Foundation and Contributors'
50+
copyright = '2017-2023, Zope Foundation and Contributors'
5151
author = 'The Zope & Plone developer community'
5252

5353
# The version info for the project you're documenting, acts as replacement for
5454
# |version| and |release|, also used in various other places throughout the
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '5.0'
58+
version = '7.0'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '5.0'
60+
release = '7.0'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.
@@ -217,7 +217,7 @@
217217
# html_search_scorer = 'scorer.js'
218218

219219
# Output file base name for HTML help builder.
220-
htmlhelp_basename = 'RestrictedPythondoc'
220+
htmlhelp_basename = 'RestrictedPython_doc'
221221

222222
# -- Options for LaTeX output ---------------------------------------------
223223

docs/contributing/ast/python3_12.ast

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,27 @@ module Python version "3.12"
1414
stmt* body,
1515
expr* decorator_list,
1616
expr? returns,
17-
string? type_comment)
17+
string? type_comment,
18+
type_param* type_params)
1819
| AsyncFunctionDef(identifier name,
1920
arguments args,
2021
stmt* body,
2122
expr* decorator_list,
2223
expr? returns,
23-
string? type_comment)
24+
string? type_comment,
25+
type_param* type_params)
2426

2527
| ClassDef(identifier name,
2628
expr* bases,
2729
keyword* keywords,
2830
stmt* body,
29-
expr* decorator_list)
31+
expr* decorator_list,
32+
type_param* type_params)
3033
| Return(expr? value)
3134

3235
| Delete(expr* targets)
3336
| Assign(expr* targets, expr value, string? type_comment)
37+
| TypeAlias(expr name, type_param* type_params, expr value)
3438
| AugAssign(expr target, operator op, expr value)
3539
-- 'simple' indicates that we annotate simple name without parens
3640
| AnnAssign(expr target, expr annotation, expr? value, int simple)
@@ -182,4 +186,9 @@ module Python version "3.12"
182186
attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)
183187

184188
type_ignore = TypeIgnore(int lineno, string tag)
189+
190+
type_param = TypeVar(identifier name, expr? bound)
191+
| ParamSpec(identifier name)
192+
| TypeVarTuple(identifier name)
193+
attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)
185194
}

docs/contributing/index.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ To enable a certain functionality in RestrictedPython, do the following:
9191
* icemac
9292
* loechel
9393

94-
Differences between different Python versions
95-
---------------------------------------------
94+
Differences between Python versions
95+
-----------------------------------
9696

9797
A (modified style) Copy of all Abstract Grammar Definitions for the Python versions does live in this Documentation (ast Subfolder) to help finding difference quicker by comparing files.
9898

@@ -152,14 +152,14 @@ The ``ast`` module consists of four areas:
152152
A ``NodeVisitor`` is a class of a node / AST consumer, it reads the data by stepping through the tree without modifying it.
153153
In contrast, a ``NodeTransformer`` (which inherits from a ``NodeVisitor``) is allowed to modify the tree and nodes.
154154

155-
Technical decissions on how to implement / maintain RestrictedPython (Design, Structure, Tools, ...)
156-
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
155+
Technical decisions on how to implement / maintain RestrictedPython (Design, Structure, Tools, ...)
156+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
157157

158158
RestrictedPython is a core Package of the Zope & Plone Stack.
159159
Until Version 3.6 RestrictedPython was Python 2 only, and a critical blocker for Zope & Plone.
160-
With RestrictedPython 4.0 an API compatible rewrite has happend, which supports modern Python Versions.
160+
With RestrictedPython 4.0 an API compatible rewrite has happened, which supports modern Python Versions.
161161

162-
* Use modern python tool stack for maintainance and tests
162+
* Use modern python tool stack for maintenance and tests
163163

164164
* tox
165165
* pytest
@@ -179,15 +179,15 @@ With RestrictedPython 4.0 an API compatible rewrite has happend, which supports
179179
Resolve discussion about how RestrictedPython should be treat new expressions / ``ast.Nodes``.
180180
This belongs to :ref:`new_python_version`.
181181

182-
**Option 1 - reduce maintainance burden (prefered by icemac)**
182+
**Option 1 - reduce maintenance burden (preferred by icemac)**
183183

184184

185185
All AST Nodes without an explicit ``visit_<AST Node>`` method, are denied by default.
186186
So the usage of this expression and functionality is not allowed.
187187

188188
*This is currently the promoted version.*
189189

190-
**Option 2 - be as explicite as possible (prefered by loechel)**
190+
**Option 2 - be as explicit as possible (preferred by loechel)**
191191

192192
If the new AST Node should be disabled by default, add a ``visit_<AST Node>`` method such as the following:
193193

@@ -237,12 +237,12 @@ Technical Backgrounds - Links to External Documentation
237237

238238
* AST Grammar of Python (`Status of Python Versions`_)
239239

240-
* `Python 3.12 AST`_ (development branch - EOL 2028-10)
241-
* `Python 3.11 AST`_ (in bugfix phase - EOL 2027-10)
242-
* `Python 3.10 AST`_ (in bugfix phase - EOL 2026-10)
243-
* `Python 3.9 AST`_ (in security phase - EOL 2025-10)
244-
* `Python 3.8 AST`_ (in security phase - EOL 2024-10)
245-
* `Python 3.7 AST`_ (in security phase - EOL 2023-06-27)
240+
* `Python 3.12 AST`_ (EOL 2028-10)
241+
* `Python 3.11 AST`_ (EOL 2027-10)
242+
* `Python 3.10 AST`_ (EOL 2026-10)
243+
* `Python 3.9 AST`_ (EOL 2025-10)
244+
* `Python 3.8 AST`_ (EOL 2024-10)
245+
* `Python 3.7 AST`_ (EOL 2023-06-27)
246246

247247
* `AST NodeVistiors Class`_
248248
* `AST NodeTransformer Class`_

docs/roadmap/index.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ Full code coverage tests.
2626

2727
stephan-hof did propose a solution, should be discussed and if approved implemented.
2828

29-
RestrictedPython 4.1+
30-
---------------------
31-
32-
Enhance RestrictedPython, declare deprecations and possible new restrictions.
33-
3429
RestrictedPython 6.0+
3530
---------------------
3631

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def read(*rnames):
5252
'Programming Language :: Python :: 3.9',
5353
'Programming Language :: Python :: 3.10',
5454
'Programming Language :: Python :: 3.11',
55+
'Programming Language :: Python :: 3.12',
5556
'Programming Language :: Python :: Implementation :: CPython',
5657
'Topic :: Security',
5758
],

0 commit comments

Comments
 (0)