From 34c036cde4ed75e000be2d29f542a3f9ec215dfa Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Thu, 24 May 2012 08:28:14 -0400 Subject: Fixed a bug with the lxml treebuilder that prevented the user from adding attributes to a tag that didn't originally have any. [bug=1002378] Thanks to Oliver Beattie for the patch. --- bs4/builder/_lxml.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bs4/builder/_lxml.py') diff --git a/bs4/builder/_lxml.py b/bs4/builder/_lxml.py index 6491322..c78fdff 100644 --- a/bs4/builder/_lxml.py +++ b/bs4/builder/_lxml.py @@ -88,6 +88,9 @@ class LXMLTreeBuilderForXML(TreeBuilder): self.nsmaps = None def start(self, name, attrs, nsmap={}): + # Make sure attrs is a mutable dict--lxml may send an immutable dictproxy. + attrs = dict(attrs) + nsprefix = None # Invert each namespace map as it comes in. if len(nsmap) == 0 and self.nsmaps != None: -- cgit v1.2.3