File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -298,13 +298,17 @@ def __copy__(self):
298
298
299
299
copy = __copy__
300
300
301
- def __deepcopy__ (self ):
301
+ def __deepcopy__ (self , memo = None ):
302
302
"""
303
303
Returns a deepcopy of the `Path`. The `Path` will not be
304
304
readonly, even if the source `Path` is.
305
305
"""
306
+ try :
307
+ codes = self .codes .copy ()
308
+ except AttributeError :
309
+ codes = None
306
310
return self .__class__ (
307
- self .vertices .copy (), self . codes . copy () ,
311
+ self .vertices .copy (), codes ,
308
312
_interpolation_steps = self ._interpolation_steps )
309
313
310
314
deepcopy = __deepcopy__
Original file line number Diff line number Diff line change 1
1
from __future__ import (absolute_import , division , print_function ,
2
2
unicode_literals )
3
+ import copy
3
4
4
5
import six
5
6
@@ -172,6 +173,16 @@ def test_path_to_polygons():
172
173
assert_array_equal (p .to_polygons (closed_only = False ), [data ])
173
174
174
175
176
+ def test_path_deepcopy ():
177
+ # Should not raise any error
178
+ verts = [[0 , 0 ], [1 , 1 ]]
179
+ codes = [Path .MOVETO , Path .LINETO ]
180
+ path1 = Path (verts )
181
+ path2 = Path (verts , codes )
182
+ copy .deepcopy (path1 )
183
+ copy .deepcopy (path2 )
184
+
185
+
175
186
if __name__ == '__main__' :
176
187
import nose
177
188
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
You can’t perform that action at this time.
0 commit comments