Skip to content

Commit a00bcca

Browse files
committed
copy in splice() just to be safe
1 parent d5dcfe3 commit a00bcca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

unpythonic/syntax/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Utilities for working with syntax."""
33

44
from functools import partial
5+
from copy import deepcopy
56
import re
67

78
from ast import (Call, Name, Attribute, Lambda, FunctionDef,
@@ -466,7 +467,9 @@ def splice(tree, rep, tag):
466467
def doit(tree, *, stop, **kw):
467468
if type(tree) is Name and tree.id == tag:
468469
stop()
469-
return rep
470+
# Copy just to be on the safe side. Different instances may be
471+
# edited differently by other macros expanded later.
472+
return deepcopy(rep)
470473
return tree
471474
return doit.recurse(tree)
472475

0 commit comments

Comments
 (0)