Python: deeply copy ast node tree

Viewed 2720

I'm trying to use deepcopy (from the copy module) to deeply copy a node tree from the ast module.

This doesn't seem to work. I'm getting strange errors like TypeError: required field "name" missing from FunctionDef when I use the copied result (and I checked it; it really is missing in the copied node), so it didn't correctly copied them.

Is there a trick I can make this working? Or maybe am I missing something?

1 Answers
Related