diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e742b0..88f5d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/mcpyrate/quotes.py b/mcpyrate/quotes.py index 7f74b38..6eab971 100644 --- a/mcpyrate/quotes.py +++ b/mcpyrate/quotes.py @@ -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):