summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2019-08-26 18:21:01 -0400
committerLeonard Richardson <leonardr@segfault.org>2019-08-26 18:21:01 -0400
commit344ee4494196eb41ee049761193cdad529ee59de (patch)
treeeb08e716f7da0ed1ed992ba381a094bb54640394
parent4eb30d2e0ad28c7ecf0b14682d341d10cbf53c34 (diff)
Fixed the definition of the default XML namespace when using
lxml 4.4. Patch by Isaac Muse. [bug=1840141]
-rw-r--r--CHANGELOG3
-rw-r--r--bs4/element.py5
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index cff70be..c992747 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,9 @@
and position within a line (Tag.sourcepos). Based on code by Chris
Mayo. [bug=1742921]
+* Fixed the definition of the default XML namespace when using
+ lxml 4.4. Patch by Isaac Muse. [bug=1840141]
+
* Fixed a crash when pretty-printing tags that were not created
during initial parsing. [bug=1838903]
diff --git a/bs4/element.py b/bs4/element.py
index 24d504b..d6ed020 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -46,6 +46,11 @@ def _alias(attr):
class NamespacedAttribute(unicode):
def __new__(cls, prefix, name, namespace=None):
+ if not name:
+ # This is the default namespace. Its name "has no value"
+ # per https://www.w3.org/TR/xml-names/#defaulting
+ name = None
+
if name is None:
obj = unicode.__new__(cls, prefix)
elif prefix is None: