Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e50aad

Browse files
committed
Don't rely on the ElementTree Comment factory being the tag attribute on Comments.
This is needed for xml.etree.cElementTree under 2.6 (and likely hence custominstalls of cElementTree 1.2), where the tag property is equal toxml.etree.ElementTree.Comment (i.e., the pure Python version).Similarly, don't rely on type(comment.tag), as this is just function!
1 parent4e06f37 commit3e50aad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎html5lib/treebuilders/etree.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
defgetETreeBuilder(ElementTreeImplementation,fullTree=False):
1515
ElementTree=ElementTreeImplementation
16+
ElementTreeCommentType=ElementTree.Comment("asd").tag
1617
classElement(_base.Node):
1718
def__init__(self,name,namespace=None):
1819
self._name=name
@@ -207,7 +208,7 @@ def serializeElement(element, indent=0):
207208
rv.append("|%s\"%s\""%(' '*(indent+2),element.text))
208209
ifelement.tail:
209210
finalText=element.tail
210-
elifelement.tag==ElementTree.Comment:
211+
elifelement.tag==ElementTreeCommentType:
211212
rv.append("|%s<!-- %s -->"%(' '*indent,element.text))
212213
else:
213214
assertisinstance(element.tag,text_type),"Expected unicode, got %s, %s"%(type(element.tag),element.tag)
@@ -275,7 +276,7 @@ def serializeElement(element):
275276
forchildinelement:
276277
serializeElement(child)
277278

278-
eliftype(element.tag)==type(ElementTree.Comment):
279+
elifelement.tag==ElementTreeCommentType:
279280
rv.append("<!--%s-->"%(element.text,))
280281
else:
281282
#This is assumed to be an ordinary element

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp