This version of RestrictedPython is incompatible with the version of Python shipped

Bug #1990545 reported by Lincoln Roop
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
restrictedpython (Ubuntu)
New
Undecided
Unassigned

Bug Description

The version of RestrictedPython shipped with Ubuntu jammy (4.0b3) is 4 years old and is not compatible with the version of Python that is also shipped in release jammy (Currently 3.10.4). Trying to use it results in an exception being thrown as shown below. Manually installing RestrictedPython 5.2 with "pip3 install restrictedpython==5.2" fixes this issue, can someone please update the Ubuntu package?

Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from RestrictedPython import compile_restricted, limited_builtins, safe_builtins, utility_builtins
>>> value="abs(x1 - x2)"
>>> value_code = compile_restricted(value, filename="<inline code>", mode="eval")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/RestrictedPython/compile.py", line 190, in compile_restricted
    result = _compile_restricted_mode(
  File "/usr/lib/python3/dist-packages/RestrictedPython/compile.py", line 68, in _compile_restricted_mode
    policy_instance.visit(c_ast)
  File "/usr/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 618, in visit_Expression
    return self.node_contents_visit(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 503, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.10/ast.py", line 495, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 888, in visit_Subscript
    node = self.node_contents_visit(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 503, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.10/ast.py", line 495, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 888, in visit_Subscript
    node = self.node_contents_visit(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 503, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.10/ast.py", line 495, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 898, in visit_Subscript
    args=[node.value, self.transform_slice(node.slice)],
  File "/usr/lib/python3/dist-packages/RestrictedPython/transformer.py", line 364, in transform_slice
    raise Exception("Unknown slice type: {0}".format(slice_))
Exception: Unknown slice type: <ast.Constant object at 0x7f8e24082680>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.