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 @@ -297,13 +297,17 @@ def __copy__(self):
297
297
298
298
copy = __copy__
299
299
300
- def __deepcopy__ (self ):
300
+ def __deepcopy__ (self , memo = None ):
301
301
"""
302
302
Returns a deepcopy of the `Path`. The `Path` will not be
303
303
readonly, even if the source `Path` is.
304
304
"""
305
+ try :
306
+ codes = self .codes .copy ()
307
+ except AttributeError :
308
+ codes = None
305
309
return self .__class__ (
306
- self .vertices .copy (), self . codes . copy () ,
310
+ self .vertices .copy (), codes ,
307
311
_interpolation_steps = self ._interpolation_steps )
308
312
309
313
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