Merge lp://staging/~facelessuser/beautifulsoup/lxml-fix into lp://staging/beautifulsoup
Proposed by
Isaac Muse
Status: | Merged | ||||
---|---|---|---|---|---|
Merge reported by: | Leonard Richardson | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp://staging/~facelessuser/beautifulsoup/lxml-fix | ||||
Merge into: | lp://staging/beautifulsoup | ||||
Diff against target: |
12 lines (+1/-1) 1 file modified
bs4/element.py (+1/-1) |
||||
To merge this branch: | bzr merge lp://staging/~facelessuser/beautifulsoup/lxml-fix | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Leonard Richardson | Pending | ||
Review via email: mp+371305@code.staging.launchpad.net |
Commit message
This fixes the current breakage with xmlns caused by lxml 4.4.0+
Description of the change
This fixes the current breakage caused by lxml 4.4.0 where xmlns with no defined prefix would be treated as an attribute 'xmlns:' which would cause the xml document to be malformed. The issue is caused by the fact that lxml now returns, in this specific case, the prefix as 'xmlns' and the name as an empty string instead of None. Moving forward, bs4 will now check if the name is either None or empty in order to handle the scenario properly.
To post a comment you must log in.
I'm not sure if we want to force " obj.name = name" to be None in this case? Or just assign the empty string. Let me know what you think. In that case, it may make more sense to do something like this:
def __new__(cls, prefix, name, namespace=None):
if not name:
name = None
if name is None: __new__ (cls, prefix) __new__ (cls, name) __new__ (cls, prefix + ":" + name)
obj.namespace = namespace
obj = unicode.
elif prefix is None:
# Not really namespaced.
obj = unicode.
else:
obj = unicode.
obj.prefix = prefix
obj.name = name
return obj