From e01bdf2432511b8bf51ecfd4fb46f140dbedae04 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Wed, 20 Aug 2014 15:25:17 +0100 Subject: [PATCH] Define __copy__ and __deepcopy__ as identity functions on DomainSpecificString, so that copy.deepcopy() will work on them --- synapse/types.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/synapse/types.py b/synapse/types.py index b8e191bb3..fd6a3d1d7 100644 --- a/synapse/types.py +++ b/synapse/types.py @@ -38,6 +38,14 @@ class DomainSpecificString( def __iter__(self): raise ValueError("Attempted to iterate a %s" % (type(self).__name__)) + # Because this class is a namedtuple of strings and booleans, it is deeply + # immutable. + def __copy__(self): + return self + + def __deepcopy__(self, memo): + return self + @classmethod def from_string(cls, s, hs): """Parse the string given by 's' into a structure object."""