Registry / serialization / pydantic-monty

pydantic-monty

JSON →
library0.0.18pypypi✓ verified 85d ago

Pydantic-Monty provides Python bindings for the Monty sandboxed Python interpreter, a Rust-based virtual machine designed for securely executing untrusted Python code. It is currently at version 0.0.12 and sees frequent, rapid releases as it is under active development, indicating ongoing feature additions and potential API changes.

pip install pydantic-monty
INSTALL
IMPORT
SIG · PYDANTIC-MONTY
P
pydantic-monty
serializationpythonv0.0.18
Install
2.1s avg
Import
Disk
36MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.18 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 2.68s
py 3.11
✓ —
✓ 1.95s
py 3.12
✓ —
✓ 1.85s
py 3.13
✓ —
✓ 1.8s
py 3.9
✕ build_error
✕ build_error
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Monty
from pydantic_monty import Monty
from monty import Monty

This quickstart demonstrates how to initialize the Monty VM, execute Python code within its sandboxed environment, and handle exceptions raised by the VM.

from monty import Monty, VmException # Initialize the Monty VM vm = Monty() # Run some simple Python code inside the VM result = vm.run('x = 10\ny = 20\nprint(x + y)') print(f'stdout: {result.stdout.strip()!r}') print(f'stderr: {result.stderr.strip()!r}') print(f'return_value: {result.return_value!r}') # Example of handling a VM-level exception try: vm.run('raise ValueError("Something went wrong in the sandbox!")') except VmException as e: print(f'VM error caught: {e}')
Debug
Known issues
gotchaMonty's VM is a sandboxed environment, meaning it has restricted access to many standard Python modules (e.g., `os`, `sys`, networking) and system resources by default. Code running within Monty cannot access the host filesystem or network unless explicitly configured (e.g., via `mount`).
fix
Review Monty's documentation for available built-ins and how to securely expose specific host resources like file paths via `vm.mount()` if necessary. Do not expect full standard library functionality without explicit configuration.
affects: All versions
gotchaAs of v0.0.12, the `zip()` built-in function in Monty enforces strict mode, raising a `ValueError` if iterables passed to it have different lengths. This differs from standard Python 3's `zip()`, which truncates to the shortest iterable.
fix
Ensure all iterables passed to `zip()` within Monty's VM have the same length. If different lengths are expected, manually handle the shorter iterable's termination or implement custom zipping logic.
affects: >=0.0.12
breakingThe library is in early development (`0.0.x` versioning), which means APIs are subject to change without strict adherence to semantic versioning. Breaking changes may occur in minor or patch releases.
fix
Pin your `pydantic-monty` dependency to an exact version (e.g., `pydantic-monty==0.0.12`) and review release notes carefully when upgrading to newer versions to identify potential breaking changes.
affects: All `0.0.x` versions
Upgrade
Version history
0.0.18latest on PyPI · released May 29, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources
pydantic-monty — pip install pydantic-monty · libregistry