File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 88
99import matplotlib as mpl
1010from matplotlib .backend_bases import MouseEvent
11+ from matplotlib .font_manager import FontProperties
1112import matplotlib .patches as mpatches
1213import matplotlib .pyplot as plt
1314import matplotlib .transforms as mtransforms
1415from matplotlib .testing .decorators import check_figures_equal , image_comparison
16+ from matplotlib .text import Text
1517
1618
1719needs_usetex = pytest .mark .skipif (
@@ -697,3 +699,13 @@ def test_transform_rotates_text():
697699 transform_rotates_text = True )
698700 result = text .get_rotation ()
699701 assert_almost_equal (result , 30 )
702+
703+
704+ def test_update_mutate_input ():
705+ inp = dict (fontproperties = FontProperties (weight = "bold" ),
706+ bbox = None )
707+ cache = dict (inp )
708+ t = Text ()
709+ t .update (inp )
710+ assert inp ['fontproperties' ] == cache ['fontproperties' ]
711+ assert inp ['bbox' ] == cache ['bbox' ]
Original file line number Diff line number Diff line change @@ -172,6 +172,8 @@ def __init__(self,
172172
173173 def update (self , kwargs ):
174174 # docstring inherited
175+ # make a copy so we do not mutate user input!
176+ kwargs = dict (kwargs )
175177 sentinel = object () # bbox can be None, so use another sentinel.
176178 # Update fontproperties first, as it has lowest priority.
177179 fontproperties = kwargs .pop ("fontproperties" , sentinel )
You can’t perform that action at this time.
0 commit comments