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

Commit66b8034

Browse files
committed
Update lint filter for Py3 and namespaced attributes.
1 parent9a37828 commit66b8034

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

‎html5lib/filters/lint.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
fromgettextimportgettext
44
_=gettext
55

6+
fromsiximporttext_type
7+
68
from .import_base
79
from ..constantsimportcdataElements,rcdataElements,voidElements
810

@@ -24,7 +26,7 @@ def __iter__(self):
2426
name=token["name"]
2527
ifcontentModelFlag!="PCDATA":
2628
raiseLintError(_("StartTag not in PCDATA content model flag: %(tag)s")% {"tag":name})
27-
ifnotisinstance(name,str):
29+
ifnotisinstance(name,text_type):
2830
raiseLintError(_("Tag name is not a string: %(tag)r")% {"tag":name})
2931
ifnotname:
3032
raiseLintError(_("Empty tag name"))
@@ -34,12 +36,14 @@ def __iter__(self):
3436
raiseLintError(_("Non-void element reported as EmptyTag token: %(tag)s")% {"tag":token["name"]})
3537
iftype=="StartTag":
3638
open_elements.append(name)
37-
forname,valueintoken["data"]:
38-
ifnotisinstance(name,str):
39+
for (ns,name),valueintoken["data"].items():
40+
ifnsisnotNoneandnotisinstance(ns,text_type):
41+
raiseLintError(_("Attribute namespace is not None or a string: %(name)r")% {"name":name})
42+
ifnotisinstance(name,text_type):
3943
raiseLintError(_("Attribute name is not a string: %(name)r")% {"name":name})
4044
ifnotname:
4145
raiseLintError(_("Empty attribute name"))
42-
ifnotisinstance(value,str):
46+
ifnotisinstance(value,text_type):
4347
raiseLintError(_("Attribute value is not a string: %(value)r")% {"value":value})
4448
ifnameincdataElements:
4549
contentModelFlag="CDATA"
@@ -50,7 +54,7 @@ def __iter__(self):
5054

5155
eliftype=="EndTag":
5256
name=token["name"]
53-
ifnotisinstance(name,str):
57+
ifnotisinstance(name,text_type):
5458
raiseLintError(_("Tag name is not a string: %(tag)r")% {"tag":name})
5559
ifnotname:
5660
raiseLintError(_("Empty tag name"))
@@ -67,7 +71,7 @@ def __iter__(self):
6771

6872
eliftypein ("Characters","SpaceCharacters"):
6973
data=token["data"]
70-
ifnotisinstance(data,str):
74+
ifnotisinstance(data,text_type):
7175
raiseLintError(_("Attribute name is not a string: %(name)r")% {"name":data})
7276
ifnotdata:
7377
raiseLintError(_("%(type)s token with empty data")% {"type":type})
@@ -80,7 +84,7 @@ def __iter__(self):
8084
name=token["name"]
8185
ifcontentModelFlag!="PCDATA":
8286
raiseLintError(_("Doctype not in PCDATA content model flag: %(name)s")% {"name":name})
83-
ifnotisinstance(name,str):
87+
ifnotisinstance(name,text_type):
8488
raiseLintError(_("Tag name is not a string: %(tag)r")% {"tag":name})
8589
# XXX: what to do with token["data"] ?
8690

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp