dart_monty_core 0.18.1
dart_monty_core: ^0.18.1 copied to clipboard
Sandboxed Python scripting for Dart. Low-level binding for pydantic/monty's interpreter.
Changelog #
0.18.1 #
Added #
open()/ file I/O.memoryMountedOsHandlernow services theOpenOS-call (existence-check forr/rb, truncate-create forw/wb, create-preserving fora/ab) and theappend_text/append_bytescalls the interpreter emits. Python canopen()files, read/write/append, and usewith open(...) as f:against an in-memory mount. A newMontyFileHandleMontyValuerepresents the returned file object.resolveOpenCall(...)— the store-agnosticopen()primitive that owns the mode→effect mapping (existence-check / truncate / create → file handle, with typed errors).memoryMountedOsHandlerdelegates to it, and anyOsCallHandler(e.g. apackage:file-backed one) can supportopen()by supplying itsexists/truncate/createIfMissingprimitives.- Typed OS exceptions. OS-handler errors are now delivered to Python as
their real class —
except FileNotFoundError:/PermissionError:etc. work. Previously everyOsCallExceptionsurfaced asRuntimeError(REPL/run path). New FFI + WASM resume entry points:monty_repl_resume_with_exceptionandDartMontyBridge.replResumeWithException.
Fixed #
memoryMountedOsHandler'sPath.read_bytesnow returns a typed bytes value instead of a bare list, so binaryopen(..., 'rb').read()buffers correctly.
Changed #
- Snapshot bytecode format (monty 0.18, breaking). The upgrade changed
monty's instruction encoding: the
monty_snapshotbyte stream for"2 + 2"shrank from 74 to 60 bytes. Snapshots are NOT portable across the 0.17 → 0.18 upgrade — consumers persisting snapshots across versions must regenerate them. Pinned bysnapshot_format_pinninginnative/tests/integration.rs.
Known limitations #
with__cm_*use monty's synthetic_test_cm(), which only exists under the testing-onlytest-hookscargo feature (never shipped). They have dedicated conformance on both backends via opt-in test-hooks builds that never touch the shipped binaries:bash tool/test_cm.sh(FFI — marker-gated oracle + dylib) andbash tool/test_cm_wasm.sh(WASM — a staged test-hooks.wasmwith the corpus runner compiled-DMONTY_TEST_HOOKS=true). The default suites skip them. Realwith open(...)is covered bywith__all.range__opsexercises2**63range membership where the shared monty wasm32 engine diverges from native; skipped on the WASM runners only.edge__int_float_mod(int % float) should yield a float; native FFI returns2.0but the monty wasm32 engine returns2(an upstream wasm number-coercion divergence). Skipped on the WASM runners only; the reverseedge__float_int_modis unaffected.open__fs/open__fs_windowsandpyobject__cycle_*pass on both backends.
0.18.0 #
Tracks upstream monty v0.0.18.
Changed #
- Upgraded the embedded interpreter to
montyv0.0.18. Headline upstream additions: anopen()builtin with buffered file I/O andwith/ context-manager support, plus a large batch of garbage-collector, exception-safety, and performance fixes. resolveFuturesper-call errors are now catchable in Python. Anerrorsentry onresolveFuturesis raised as aRuntimeErrorat theawaitpoint, so a wrappingtry/except RuntimeErrorcatches it normally. Previously this short-circuited past Python's exception handling and terminated the script withMontyScriptError. Scripts that relied on the old script-terminating behavior (without atry/except) still surface a terminal error.
Build #
- Building from source now requires Rust 1.95+ (upstream
montyv0.0.18 raised its MSRV). Runrustup update stable.
Known limitations #
Some v0.0.18 interpreter features are not yet surfaced through this binding. Their corpus fixtures are skipped in the WASM runners (and pass the oracle suite only because FFI and the oracle binary agree on the same gap):
open()/ file I/O — the newOpenOS-call is not yet dispatched through the Dart OS handler + WASM VFS (open__fs,open__fs_windows,with__all).withcontext-manager edge cases driven by thetest-hooks-only_test_cm()synthetic CM (with__cm_*) — not built into the shipped crate.- Cyclic-container result comparison in the WASM fixture runner
(
pyobject__cycle_*); FFI returns the correct cyclic value. range__ops— dart2js divergence on2**63-scale range membership.
Internal #
- Adapted the native shim to v0.0.18's restructured
OsCall(function/args/kwargsfields replaced by a typedfunction_callprojected viatake_function_call().to_args()) and added a JSON mapping for the newMontyObject::FileHandlevariant. The new file-handle value currently decodes on the Dart side as a genericMontyDict(__type: "filehandle"); a dedicatedMontyValuesubtype is a follow-up.
0.17.1 #
Breaking #
MontyCallbackis now(List<Object?> args, Map<String, Object?>? kwargs). Positional args by index (args[0]…); keyword args inkwargs. Old single-map form (args['_0']) no longer compiles..argumentsrenamed to.argsonMontyPending,MontyOsCall,CoreProgressResult, andWasmProgressResult.useFuturesremoved fromfeedRun/feedStart/Monty.run. UseexternalAsyncFunctionsinstead.
Added #
inputs:onMonty.run/feedRun/feedStart— inject Dart values as Python variables for one execution.externalAsyncFunctions— callbacks dispatched viaresumeAsFuture; Python canawaitthem andasyncio.gatherruns them concurrently.MontyInternalError— newMontyErrorsubtype for interpreter-internal failures.MontyNoneliteral —feedRun('None')now returnsMontyNone.
0.17.0 #
Re-cut release: align versioning with dart_monty. Supersedes the
retracted 0.0.17 (which omitted native/src/bin/oracle.rs from
the published archive, breaking the build hook for consumers).
0.0.17 #
Initial release.