Skip to content

Commit

Permalink
fix crash in splice_ast_literals on Nonlocal and Global AST nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Technologicat committed Apr 28, 2021
1 parent e93a7b1 commit 0e6ec76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

- Fix bug in quasiquoting of constants: support also `...` (the `Ellipsis` singleton).

- Fix bug in `splice_ast_literals` (a.k.a. run-time part of `q`) that made it crash on `ast.Nonlocal` and `ast.Global` nodes.

- Fix bug in type preservation of empty list in `ASTTransformer`.

- Fix bug in copy support of `ASTMarker` objects. Now it is possible to deepcopy ASTs that contain markers.
Expand Down
4 changes: 4 additions & 0 deletions mcpyrate/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ def doit(thing):
doit(item)
newthing.append(item)
thing[:] = newthing
# As of Python 3.9, `Global` and `Nonlocal` are the only AST node types
# where a field contains a `list` of bare strings.
elif isinstance(thing, (ast.Global, ast.Nonlocal)):
pass
elif isinstance(thing, ast.AST):
for fieldname, value in ast.iter_fields(thing):
if isinstance(value, list):
Expand Down

0 comments on commit 0e6ec76

Please sign in to comment.