Skip to content

Commit e2a495a

Browse files
author
Michael Howitz
authored
Fix code to run on Python 3.11.0b3. (#229)
* Fix coveralls.
1 parent ee4e4d6 commit e2a495a

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- ["3.8", "py38"]
2828
- ["3.9", "py39"]
2929
- ["3.10", "py310"]
30-
- ["3.11.0-beta.1", "py311"]
30+
- ["3.11.0-beta.3", "py311"]
3131
- ["3.9", "docs"]
3232
- ["3.9", "coverage"]
3333
- ["3.9", "py39-datetime"]

.meta.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
33
[meta]
44
template = "pure-python"
5-
commit-id = "5461bae88c19d8d771ba2bd5f00c69540580335d"
5+
commit-id = "b4cfc9ca6065ca82646fa69d04ee4c15c58035e1"
66

77
[python]
88
with-pypy = false
@@ -44,6 +44,7 @@ testenv-additional = [
4444
" COVERAGE_FILE=.coverage",
4545
"commands =",
4646
" mkdir -p {toxinidir}/parts/htmlcov",
47+
" coverage erase",
4748
" coverage combine",
4849
" coverage html",
4950
" coverage report -m --fail-under=100",
@@ -56,7 +57,7 @@ coverage-setenv = [
5657
]
5758

5859
[coverage]
59-
fail-under = 98.7
60+
fail-under = 98.8
6061

6162
[manifest]
6263
additional-rules = [

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Features
1515
- Allow to use the package with Python 3.11 -- Caution: No security audit has
1616
been done so far.
1717

18+
- Fix code to run on Python 3.11.0b3.
19+
1820

1921
5.2 (2021-11-19)
2022
----------------

src/RestrictedPython/transformer.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,24 @@
6464
])
6565

6666

67-
# When new ast nodes are generated they have no 'lineno' and 'col_offset'.
68-
# This function copies these two fields from the incoming node
67+
# When new ast nodes are generated they have no 'lineno', 'end_lineno',
68+
# 'col_offset' and 'end_col_offset'. This function copies these fields from the
69+
# incoming node:
6970
def copy_locations(new_node, old_node):
7071
assert 'lineno' in new_node._attributes
7172
new_node.lineno = old_node.lineno
7273

74+
if IS_PY38_OR_GREATER:
75+
assert 'end_lineno' in new_node._attributes
76+
new_node.end_lineno = old_node.end_lineno
77+
7378
assert 'col_offset' in new_node._attributes
7479
new_node.col_offset = old_node.col_offset
7580

81+
if IS_PY38_OR_GREATER:
82+
assert 'end_col_offset' in new_node._attributes
83+
new_node.end_col_offset = old_node.end_col_offset
84+
7685
ast.fix_missing_locations(new_node)
7786

7887

@@ -427,6 +436,9 @@ def inject_print_collector(self, node, position=0):
427436
if isinstance(node, ast.Module):
428437
_print.lineno = position
429438
_print.col_offset = position
439+
if IS_PY38_OR_GREATER:
440+
_print.end_lineno = position
441+
_print.end_col_offset = position
430442
ast.fix_missing_locations(_print)
431443
else:
432444
copy_locations(_print, node)

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ setenv =
4646
COVERAGE_FILE=.coverage
4747
commands =
4848
mkdir -p {toxinidir}/parts/htmlcov
49+
coverage erase
4950
coverage combine
5051
coverage html
5152
coverage report -m --fail-under=100
@@ -100,7 +101,7 @@ commands =
100101
pytest --cov=src --cov=tests --cov-report= {posargs}
101102
coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
102103
coverage html
103-
coverage report -m --fail-under=98.7
104+
coverage report -m --fail-under=98.8
104105

105106
[coverage:run]
106107
branch = True

0 commit comments

Comments
 (0)