summaryrefslogtreecommitdiff
path: root/bs4/builder/_lxml.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2019-01-06 18:42:02 -0500
committerLeonard Richardson <leonardr@segfault.org>2019-01-06 18:42:02 -0500
commit4ea083fedb7bc813e7f4677b437488588d399c37 (patch)
tree30ca6313e245fd6e30d601ecb218e2f84812d878 /bs4/builder/_lxml.py
parent48c7ad53dade2827e89984ff40561f2d70bb6e46 (diff)
parentde264e1294a5e2a9a00685e729f2eb0ec5129330 (diff)
downloadbeautifulsoup4-4ea083fedb7bc813e7f4677b437488588d399c37.tar.gz
Beautiful Soup will no longer try to keep track of namespaces that
are not defined with a prefix; this can confuse soupselect. [bug=1810680]
Diffstat (limited to 'bs4/builder/_lxml.py')
-rw-r--r--bs4/builder/_lxml.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/bs4/builder/_lxml.py b/bs4/builder/_lxml.py
index 3a1700c..b7e172c 100644
--- a/bs4/builder/_lxml.py
+++ b/bs4/builder/_lxml.py
@@ -71,12 +71,12 @@ class LXMLTreeBuilderForXML(TreeBuilder):
This might be useful later on when creating CSS selectors.
"""
for key, value in mapping.items():
- if key not in self.soup._namespaces:
- # Let the BeautifulSoup object know about a new namespace.
- # If there are multiple namespaces defined with the same
- # prefix, the first one in the document takes precedence.
- self.soup._namespaces[key] = value
-
+ if key and key not in self.soup._namespaces:
+ # Let the BeautifulSoup object know about a new namespace.
+ # If there are multiple namespaces defined with the same
+ # prefix, the first one in the document takes precedence.
+ self.soup._namespaces[key] = value
+
def default_parser(self, encoding):
# This can either return a parser object or a class, which
# will be instantiated with default arguments.