{"categories":[{"label":"Security","url":"https://skillfed.io/packages/category/security"}],"enrichment":{"capability":"RestrictedPython compiles and executes a restricted subset of Python code in a controlled environment, preventing access to dangerous operations like arbitrary imports and unsafe attribute access.","skillfed_tags":["code-execution","sandboxing","untrusted-code"],"use_cases":["Execute user-supplied scripts or formulas in a web application without granting access to the filesystem or system calls.","Provide a templating or rule-engine system where end users can write logic without risking the host application.","Sandbox third-party plugins or extensions to prevent them from accessing sensitive APIs or data.","Implement a restricted REPL or notebook environment for educational or demonstration purposes.","Validate and restrict Python code before passing it to a workflow or job queue system."],"what_it_does":"RestrictedPython is a code compiler that transforms Python source into a restricted subset suitable for executing untrusted code in a controlled environment. It intercepts dangerous operations\u2014such as arbitrary imports, unsafe attribute access, and format string exploits\u2014by rewriting the compiled bytecode to route these operations through guarded functions that you control. The package is not a sandbox or a security guarantee; rather, it provides the machinery to define a trusted execution context and enforce restrictions within it.\n\nYou supply Python source code, compile it with compile_restricted(), and execute the resulting bytecode in a namespace you define (typically using safe_globals as a baseline). RestrictedPython prevents access to internals like __import__, restricts attribute traversal via safer_getattr, and blocks syntax constructs deemed unsafe (such as try/except* in recent versions). It has been maintained since 2007 and currently supports Python 3.10 through 3.14 on CPython only.","worth_installing":"Yes, if you need to execute untrusted Python code with controlled restrictions. RestrictedPython is mature, actively maintained, and has no known vulnerabilities. However, it is not a complete sandbox\u2014it requires careful design of your safe_globals and guard functions to be effective. Verify the ZPL-2.1 license compatibility for your use case, and confirm that CPython-only support meets your deployment requirements."},"id":"restrictedpython","links":{"html":"https://skillfed.io/packages/restrictedpython","md":"https://skillfed.io/packages/restrictedpython.md","pypi":"https://pypi.org/project/restrictedpython/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2026-07-10","license_spdx":"ZPL-2.1","license_treatment":"unclear","name":"RestrictedPython","python_support":"supports_current","summary":"RestrictedPython is a defined subset of the Python language which allows to provide a program input into a trusted environment."},"popularity":{"monthly_downloads":8872727,"position":1584,"tier":"top_5000"},"security":{"n_vulnerabilities":0},"version":"8.4"}
