Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changes

- Drop support for Python 3.9.

- Allow the ``...`` (Ellipsis) statement.


8.1 (2025-10-19)
----------------
Expand Down
1 change: 1 addition & 0 deletions src/RestrictedPython/Guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'None',
'False',
'True',
'Ellipsis',
'abs',
'bool',
'bytes',
Expand Down
10 changes: 1 addition & 9 deletions src/RestrictedPython/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,20 +476,12 @@ def node_contents_visit(self, node):
# ast for Literals

def visit_Constant(self, node):
"""Allow constant literals with restriction for Ellipsis.
"""Allow constant literals.

Constant replaces Num, Str, Bytes, NameConstant and Ellipsis in
Python 3.8+.
:see: https://docs.python.org/dev/whatsnew/3.8.html#deprecated
"""
if node.value is Ellipsis:
# Deny using `...`.
# Special handling necessary as ``self.not_allowed(node)``
# would return the Error Message:
# 'Constant statements are not allowed.'
# which is only partial true.
self.error(node, 'Ellipsis statements are not allowed.')
return
return self.node_contents_visit(node)

def visit_Interactive(self, node):
Expand Down
7 changes: 3 additions & 4 deletions tests/transformer/test_base_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from RestrictedPython import compile_restricted_exec
from tests.helper import restricted_eval


Expand All @@ -18,6 +17,6 @@ def test_Set():


def test_Ellipsis():
"""It prevents using the `ellipsis` statement."""
result = compile_restricted_exec('...')
assert result.errors == ('Line 1: Ellipsis statements are not allowed.',)
"""It allows to use the `ellipsis` statement."""
assert restricted_eval('...') == ...
assert restricted_eval('Ellipsis') == ...
Loading