Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fded0d5

Browse files
committed
Fix mutable default arguments in XMLWriter
1 parent ce8a66e commit fded0d5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/matplotlib/backends/backend_svg.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __flush(self, indent=True):
133133
self.__write(_escape_cdata(data))
134134
self.__data = []
135135

136-
def start(self, tag, attrib={}, **extra):
136+
def start(self, tag, attrib=None, **extra):
137137
"""
138138
Open a new element. Attributes can be given as keyword
139139
arguments, or as a string/string dictionary. The method returns
@@ -152,6 +152,8 @@ def start(self, tag, attrib={}, **extra):
152152
-------
153153
An element identifier.
154154
"""
155+
if attrib is None:
156+
attrib = {}
155157
self.__flush()
156158
tag = _escape_cdata(tag)
157159
self.__data = []
@@ -232,12 +234,14 @@ def close(self, id):
232234
while len(self.__tags) > id:
233235
self.end()
234236

235-
def element(self, tag, text=None, attrib={}, **extra):
237+
def element(self, tag, text=None, attrib=None, **extra):
236238
"""
237239
Add an entire element. This is the same as calling :meth:`start`,
238240
:meth:`data`, and :meth:`end` in sequence. The *text* argument can be
239241
omitted.
240242
"""
243+
if attrib is None:
244+
attrib = {}
241245
self.start(tag, attrib, **extra)
242246
if text:
243247
self.data(text)

0 commit comments

Comments
 (0)