Repository navigation
Unwrap EvalLocalVar in nested @pyscript_compile/@pyscript_executor - #947
Open
EnesKartal wants to merge 1 commit into
Open
EnesKartal wants to merge 1 commit into
EnesKartal wants to merge 1 commit into
Conversation
craigbarratt
reviewed
Dec 4, 2026
craigbarratt
left a comment
Member
There was a problem hiding this comment.
Thanks @EnesKartal, nice fix.
One small request: when the local isn't assigned yet, could _LocalSymTable.__getitem__ raise UnboundLocalError(f"local variable '{key}' referenced before assignment") instead of the NameError? That's what CPython raises, and it matches pyscript's message for reading an unassigned local elsewhere. The new exception test would then expect UnboundLocalError with that message. Happy to approve after that.
Member
|
Small update to my request: #950 just switched pyscript to CPython 3.14's wording, so after rebasing on master please raise |
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.
Fixes #945.
Nested @pyscript_compile\ and @pyscript_executor\ functions were compiled via \exec()\ with \self.sym_table\ directly as \locals, causing default arguments (and other decorators) referencing enclosing locals to receive \EvalLocalVar\ cells instead of their values. This wraps \self.sym_table\ in a read-through _LocalSymTable\ view when in a local scope so \exec()\ unwraps \EvalLocalVar\ entries (and raises \NameError\ for undefined locals) without overwriting the enclosing function's cell.
Verified with \pytest\ (307 passed),
uff check,
uff format --check, \mypy, and \pylint.