You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
), 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")
I can create a PR, but I need to figure out what the solution is. Disallow "function" or, by analogy with compile_restricted_function, replace it with "exec" or something else?
upd: just replacing it won't do any good.
it's not work on RestrictedPython 6.0 (03.11.2022) and python 3.6 (minimum version for RestrictedPython 6.0).
It probably never worked.
History:
0) commit 0
When developing the new api in version 4.0, compile_restricted_function had a signature matching the backward compile_restricted_* methods. compile_restricted called compile_restricted_[mode]
commit 1
The function _compile_restricted_mode is highlighted, compile_restricted_function calls it with mode='function', and the function compile_restricted starts calling _compile_restricted_mode directly with mode='exec'.
1.1) commit 1.1
The compile_restricted function starts calling _compile_restricted_mode directly with mode=mode.
commit 2
The signature of the compile_restricted_function function is changing.
cimmit 3
The function compile_restricted_function has an implementation.
I think we should just delete it. And since it didn't actually work in any release, I think you don't need to increase the major version number.
@zedzhen Thank you for the analysis. Yes, let's delete compile_restricted_function and its mentionings in the documentation. If it never has worked, nobody ever could have used it.
Would you mind to create an independent PR just for the removal?
The compile_restricted_function is working.
When developing the new API in version 4.0, compile_restricted_function had a signature matching compile_restricted_* (and was equivalent to compile_restricted_exec) and it could be called as compile_restricted(..., mode='function'), but then (before the release) the signature was changed, and the call compile_restricted(..., mode='function'), stopped working.
Therefore, compile_restricted_function should not be deleted, and compile_restricted(..., mode='function') is deleted in #326.
Activity
zedzhen commentedon Jun 3, 2026
I can create a PR, but I need to figure out what the solution is. Disallow "function" or,
by analogy withor something else?compile_restricted_function, replace it with "exec"upd: just replacing it won't do any good.
icemac commentedon Jun 12, 2026
@loechel Do you remember what this
functionmode was for?zedzhen commentedon Jun 16, 2026
it's not work on RestrictedPython 6.0 (03.11.2022) and python 3.6 (minimum version for RestrictedPython 6.0).
It probably never worked.
History:
0) commit 0
When developing the new api in version 4.0,
compile_restricted_functionhad a signature matching the backwardcompile_restricted_*methods.compile_restrictedcalledcompile_restricted_[mode]The function
_compile_restricted_modeis highlighted,compile_restricted_functioncalls it with mode='function', and the functioncompile_restrictedstarts calling_compile_restricted_modedirectly with mode='exec'.1.1) commit 1.1
The
compile_restrictedfunction starts calling_compile_restricted_modedirectly with mode=mode.The signature of the
compile_restricted_functionfunction is changing.The function
compile_restricted_functionhas an implementation.I think we should just delete it. And since it didn't actually work in any release, I think you don't need to increase the major version number.
@icemac
icemac commentedon Jun 19, 2026
@zedzhen Thank you for the analysis. Yes, let's delete
compile_restricted_functionand its mentionings in the documentation. If it never has worked, nobody ever could have used it.Would you mind to create an independent PR just for the removal?
zedzhen commentedon Jun 19, 2026
The
compile_restricted_functionis working.When developing the new API in version 4.0,
compile_restricted_functionhad a signature matchingcompile_restricted_*(and was equivalent tocompile_restricted_exec) and it could be called ascompile_restricted(..., mode='function'), but then (before the release) the signature was changed, and the callcompile_restricted(..., mode='function'), stopped working.Therefore,
compile_restricted_functionshould not be deleted, andcompile_restricted(..., mode='function')is deleted in #326.icemac commentedon Jun 19, 2026
@zedzhen Thank you for the clarification. I just merged #326.
add comment and update type hint after fix zopefoundation#318
Type Annotations for RestrictedPython (#317)