File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -297,13 +297,17 @@ def __copy__(self):
297297
298298 copy = __copy__
299299
300- def __deepcopy__ (self ):
300+ def __deepcopy__ (self , memo = None ):
301301 """
302302 Returns a deepcopy of the `Path`. The `Path` will not be
303303 readonly, even if the source `Path` is.
304304 """
305+ try :
306+ codes = self .codes .copy ()
307+ except AttributeError :
308+ codes = None
305309 return self .__class__ (
306- self .vertices .copy (), self . codes . copy () ,
310+ self .vertices .copy (), codes ,
307311 _interpolation_steps = self ._interpolation_steps )
308312
309313 deepcopy = __deepcopy__
Original file line number Diff line number Diff line change 11from __future__ import (absolute_import , division , print_function ,
22 unicode_literals )
3+ import copy
34
45import six
56
@@ -172,6 +173,16 @@ def test_path_to_polygons():
172173 assert_array_equal (p .to_polygons (closed_only = False ), [data ])
173174
174175
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+
175186if __name__ == '__main__' :
176187 import nose
177188 nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
You can’t perform that action at this time.
0 commit comments