@@ -56,11 +56,6 @@ class Error(Exception):
56
56
pass
57
57
error = Error # backward compatibility
58
58
59
- try :
60
- from org .python .core import PyStringMap
61
- except ImportError :
62
- PyStringMap = None
63
-
64
59
__all__ = ["Error" , "copy" , "deepcopy" ]
65
60
66
61
def copy (x ):
@@ -106,23 +101,18 @@ def copy(x):
106
101
107
102
def _copy_immutable (x ):
108
103
return x
109
- for t in (type ( None ) , int , float , bool , complex , str , tuple ,
104
+ for t in (types . NoneType , int , float , bool , complex , str , tuple ,
110
105
bytes , frozenset , type , range , slice , property ,
111
- types .BuiltinFunctionType , type (Ellipsis ), type (NotImplemented ),
112
- types .FunctionType , weakref .ref ):
113
- d [t ] = _copy_immutable
114
- t = getattr (types , "CodeType" , None )
115
- if t is not None :
106
+ types .BuiltinFunctionType , types .EllipsisType ,
107
+ types .NotImplementedType , types .FunctionType , types .CodeType ,
108
+ weakref .ref ):
116
109
d [t ] = _copy_immutable
117
110
118
111
d [list ] = list .copy
119
112
d [dict ] = dict .copy
120
113
d [set ] = set .copy
121
114
d [bytearray ] = bytearray .copy
122
115
123
- if PyStringMap is not None :
124
- d [PyStringMap ] = PyStringMap .copy
125
-
126
116
del d , t
127
117
128
118
def deepcopy (x , memo = None , _nil = []):
@@ -181,9 +171,9 @@ def deepcopy(x, memo=None, _nil=[]):
181
171
182
172
def _deepcopy_atomic (x , memo ):
183
173
return x
184
- d [type ( None ) ] = _deepcopy_atomic
185
- d [type ( Ellipsis ) ] = _deepcopy_atomic
186
- d [type ( NotImplemented ) ] = _deepcopy_atomic
174
+ d [types . NoneType ] = _deepcopy_atomic
175
+ d [types . EllipsisType ] = _deepcopy_atomic
176
+ d [types . NotImplementedType ] = _deepcopy_atomic
187
177
d [int ] = _deepcopy_atomic
188
178
d [float ] = _deepcopy_atomic
189
179
d [bool ] = _deepcopy_atomic
@@ -231,8 +221,6 @@ def _deepcopy_dict(x, memo, deepcopy=deepcopy):
231
221
y [deepcopy (key , memo )] = deepcopy (value , memo )
232
222
return y
233
223
d [dict ] = _deepcopy_dict
234
- if PyStringMap is not None :
235
- d [PyStringMap ] = _deepcopy_dict
236
224
237
225
def _deepcopy_method (x , memo ): # Copy instance methods
238
226
return type (x )(x .__func__ , deepcopy (x .__self__ , memo ))
@@ -301,4 +289,4 @@ def _reconstruct(x, memo, func, args,
301
289
y [key ] = value
302
290
return y
303
291
304
- del types , weakref , PyStringMap
292
+ del types , weakref
0 commit comments