diff --git a/CHANGES.rst b/CHANGES.rst index 8230a3a..3808d7f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Changes - Allow ``ast.Module``, ``ast.Expression`` and ``ast.Interactive`` as body in compile_restricted_function +- Disallow ``mode="function"`` in ``compile_restricted`` (it never worked). + 8.3 (2026-06-16) ---------------- diff --git a/docs/usage/api.rst b/docs/usage/api.rst index 2a23e42..966aaaf 100644 --- a/docs/usage/api.rst +++ b/docs/usage/api.rst @@ -11,7 +11,7 @@ API overview :param source: (required). the source code that should be compiled :param filename: (optional). defaults to ``''`` - :param mode: (optional). Use ``'exec'``, ``'eval'``, ``'single'`` or ``'function'``. defaults to ``'exec'`` + :param mode: (optional). Use ``'exec'``, ``'eval'`` or ``'single'``. defaults to ``'exec'`` :param flags: (optional). defaults to ``0`` :param dont_inherit: (optional). defaults to ``False`` :param policy: (optional). defaults to ``RestrictingNodeTransformer`` diff --git a/src/RestrictedPython/compile.py b/src/RestrictedPython/compile.py index e95b970..244f6b6 100644 --- a/src/RestrictedPython/compile.py +++ b/src/RestrictedPython/compile.py @@ -206,7 +206,7 @@ def compile_restricted( policy ... `ast.NodeTransformer` class defining the restrictions. """ - if mode in ['exec', 'eval', 'single', 'function']: + if mode in ['exec', 'eval', 'single']: result = _compile_restricted_mode( source, filename=filename,