File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ class Error(Exception):
5757 pass
5858error = Error # backward compatibility
5959
60+ try :
61+ from ucollections import OrderedDict
62+ except ImportError :
63+ OrderedDict = None
64+
6065try :
6166 from org .python .core import PyStringMap
6267except ImportError :
@@ -121,6 +126,8 @@ def _copy_with_constructor(x):
121126 return type (x )(x )
122127for t in (list , dict , set ):
123128 d [t ] = _copy_with_constructor
129+ if OrderedDict is not None :
130+ d [OrderedDict ] = _copy_with_constructor
124131
125132def _copy_with_copy_method (x ):
126133 return x .copy ()
@@ -235,12 +242,14 @@ def _deepcopy_tuple(x, memo):
235242d [tuple ] = _deepcopy_tuple
236243
237244def _deepcopy_dict (x , memo ):
238- y = {}
245+ y = type ( x )()
239246 memo [id (x )] = y
240247 for key , value in x .items ():
241248 y [deepcopy (key , memo )] = deepcopy (value , memo )
242249 return y
243250d [dict ] = _deepcopy_dict
251+ if OrderedDict is not None :
252+ d [OrderedDict ] = _deepcopy_dict
244253if PyStringMap is not None :
245254 d [PyStringMap ] = _deepcopy_dict
246255
You can’t perform that action at this time.
0 commit comments