Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential error in rewrite fast locals on 3.12 for #548 #550

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions enaml/core/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,14 @@ def rewrite_to_fast_locals(self, local_names):
stored_names = set()
code_ops = self.code_ops
for idx, instr in enumerate(code_ops):
if not isinstance(instr, bc.Instr):
continue
if instr.name == "STORE_NAME":
stored_names.add(instr.arg)
instr.name = "STORE_FAST"
for idx, instr in enumerate(code_ops):
if not isinstance(instr, bc.Instr):
continue
i_name = instr.name
if i_name == "LOAD_NAME":
i_arg = instr.arg
Expand Down
4 changes: 4 additions & 0 deletions releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Enaml Release Notes

Dates are written as DD/MM/YYYY

0.17.1 - unreleased
-------------------
- fix possible error in rewrite fast locals when using templates on 3.12 PR #550

0.17.0 - 20/11/2023
-------------------
- support for Python 3.12 PR #535
Expand Down
18 changes: 18 additions & 0 deletions tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ def test_syntax_20():
compile_source(source, 'Main')


def test_syntax_21():
source = dedent("""\
template Other(*Args):
Slider:
pass

template Main(Model):
const args = [
m for m in Model.members().values()
if isinstance(m, Float)
]
Other(args): *all:
pass

""")
compile_source(source, 'Main')


#------------------------------------------------------------------------------
# Bad Template Syntax
#------------------------------------------------------------------------------
Expand Down
Loading