Skip to content

Commit

Permalink
Looks like we need a custom __copy__ method after all
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Slavich committed May 4, 2020
1 parent 96d47a5 commit f64413d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion asdf/tagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"""

from collections import UserDict, UserList, UserString
from copy import deepcopy
from copy import deepcopy, copy


__all__ = ['tag_object', 'get_tag']
Expand Down Expand Up @@ -68,6 +68,10 @@ def __deepcopy__(self, memo):
data_copy = deepcopy(self.data, memo)
return TaggedDict(data_copy, self._tag)

def __copy__(self):
data_copy = copy(self.data)
return TaggedDict(data_copy, self._tag)


class TaggedList(Tagged, UserList, list):
"""
Expand All @@ -90,6 +94,10 @@ def __deepcopy__(self, memo):
data_copy = deepcopy(self.data, memo)
return TaggedList(data_copy, self._tag)

def __copy__(self):
data_copy = copy(self.data)
return TaggedList(data_copy, self._tag)


class TaggedString(Tagged, UserString, str):
"""
Expand Down

0 comments on commit f64413d

Please sign in to comment.