diff --git a/CHANGELOG.md b/CHANGELOG.md index b481034..5635347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ **Fixed**: - Fix https://github.com/Technologicat/mcpyrate/issues/41. The unparser now understands the Python 3.10 pattern matching construct `match`/`case`. +- Fix bug in `rename`: rename also in `global` and `nonlocal` declarations. --- diff --git a/mcpyrate/utils.py b/mcpyrate/utils.py index 504feb9..2b73485 100644 --- a/mcpyrate/utils.py +++ b/mcpyrate/utils.py @@ -134,6 +134,10 @@ def transform(self, tree): elif T is ast.ExceptHandler: if tree.name == oldname: tree.name = newname + elif T in (ast.Global, ast.Nonlocal): + for j in range(len(tree.names)): + if tree.names[j] == oldname: + tree.names[j] = newname return self.generic_visit(tree) return Renamer().visit(tree)