Skip to content

mode="function" #318

Description

@zedzhen

BUG/PROBLEM REPORT

mode="function" is allowed for compile_restricted funcion (

if mode in ['exec', 'eval', 'single', 'function']:
result = _compile_restricted_mode(
source,
filename=filename,
mode=mode,
flags=flags,
dont_inherit=dont_inherit,
policy=policy)
), but _compile_restricted_mode simply passes mode to the ast.parse and built-in compile functions, which does not accept mode="function" (ast.parse allows "func_type", both allow "eval", "exec", "single")

from RestrictedPython.compile import compile_restricted

s = """
def f():
    pass
"""

compile_restricted(s, mode="function")

What version of Python and Zope/Addons I am using:

master branch without addons (python 3.10.11, 3.11.9, 3.12.10, 3.13.13, 3.14.5, 3.15.0b2)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions