Use copy instead of deepcopy

Deepcopy should not be used (see #7672).
Merge pull request #7674 from certik/deepcopy

Use copy instead of deepcopy