Restore the embedded Jython interpreter init#4
Draft
khatchad wants to merge 2 commits into
Draft
Conversation
`PySystemState.doInitialize` read the `_frozen_importlib` bootstrap classes from a hardcoded working-directory-relative path (`src/resources/frozen_importlib/`), so interpreter init failed with a `FileNotFoundException` (leaving `sys.importlib` null) whenever Jython was initialized from any directory other than the source-tree root — i.e. in a Maven module or OSGi bundle, which is every real embedding. Resolve via the classpath first, then under `python.home`, then the legacy relative path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`PythonInterpreter.eval(String)` wrapped the source in `PyBytes`, a leftover from the PEP-393 `PyString`->`PyBytes` rename (761f17f). Python 3's `eval()` requires a str or code object, so a bytes argument raised "eval: argument 1 must be string or code object". Wrap in `PyUnicode` instead. Only the `eval(String)` overload was affected; constant folding goes through `eval(PyObject)`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This was referenced Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft — preservation/reference branch, not ready to merge. Tracks wala/ML#580.
Two fixes that get the embedded Jython-3 interpreter initializing again (it currently fails, so all interpreter-based evaluation — constant folding, shape-argument evaluation via
interpretAsInt/evalAsInteger— degrades tonull):frozen_importlibindependent of the working directory — the bootstrap resources were read via a cwd-relativeFileInputStream, which fails outside the Jython working dir. Loads via classpath →python.home(prefix) → cwd instead. Also bundles thejnr/jffiFFI deps (fat jar) so init doesn'tNoClassDefFoundError.str, notbytes—PythonInterpreter.eval(String)wrapped the source inPyBytes;__builtin__.evalneeds astr/code object (PyUnicode). Regression from the 2016 PEP-393PyString→PyBytesrename (761f17f).Why this is a draft, not a merge
Enabling the interpreter installs
importlib, which changes howtyping.NamedTupleresolves and regresses the downstreamNamedTuple-field propagation that just shipped in wala/ML (the constructor field-population gates onNamedTuplebeing an unresolved/"missing" type). That interaction must be resolved before the interpreter can be turned back on — see wala/ML#580. This branch preserves the init fixes so they aren't lost while that blocker is worked.🤖 Generated with Claude Code