File tree 1 file changed +10
-1
lines changed 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ class Error(Exception):
57
57
pass
58
58
error = Error # backward compatibility
59
59
60
+ try :
61
+ from ucollections import OrderedDict
62
+ except ImportError :
63
+ OrderedDict = None
64
+
60
65
try :
61
66
from org .python .core import PyStringMap
62
67
except ImportError :
@@ -121,6 +126,8 @@ def _copy_with_constructor(x):
121
126
return type (x )(x )
122
127
for t in (list , dict , set ):
123
128
d [t ] = _copy_with_constructor
129
+ if OrderedDict is not None :
130
+ d [OrderedDict ] = _copy_with_constructor
124
131
125
132
def _copy_with_copy_method (x ):
126
133
return x .copy ()
@@ -235,12 +242,14 @@ def _deepcopy_tuple(x, memo):
235
242
d [tuple ] = _deepcopy_tuple
236
243
237
244
def _deepcopy_dict (x , memo ):
238
- y = {}
245
+ y = type ( x )()
239
246
memo [id (x )] = y
240
247
for key , value in x .items ():
241
248
y [deepcopy (key , memo )] = deepcopy (value , memo )
242
249
return y
243
250
d [dict ] = _deepcopy_dict
251
+ if OrderedDict is not None :
252
+ d [OrderedDict ] = _deepcopy_dict
244
253
if PyStringMap is not None :
245
254
d [PyStringMap ] = _deepcopy_dict
246
255
You can’t perform that action at this time.
0 commit comments