Skip to content

Commit

Permalink
Merge pull request #550 from frmdstryr/bc-test
Browse files Browse the repository at this point in the history
Fix potential error in rewrite fast locals on 3.12 for #548
  • Loading branch information
MatthieuDartiailh authored Apr 24, 2024
2 parents d92343f + 0e980a9 commit ca6cf4a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
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

0 comments on commit ca6cf4a

Please sign in to comment.