Skip to content

Commit a98f8a6

Browse files
tonylopesgsnedders
authored andcommitted
Using frozenset with lists to avoid problems.
It makes more sense to pass lists to frozensets since tuples need special syntax to be interpreted correctly in this context. For instance, the line "hr": frozenset(("noshade")) has a bug. It won't produce a frozenset with "noshade" but with ['a', 'e', 'd', 'h', 'o', 'n', 's'] because if you forget to add a comma at the end, the tuple won't be an iterable but the string is it interprets is.
1 parent a3c4fc0 commit a98f8a6

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

html5lib/constants.py

+40-40
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
"xmlns": "http://www.w3.org/2000/xmlns/"
299299
}
300300

301-
scopingElements = frozenset((
301+
scopingElements = frozenset([
302302
(namespaces["html"], "applet"),
303303
(namespaces["html"], "caption"),
304304
(namespaces["html"], "html"),
@@ -316,9 +316,9 @@
316316
(namespaces["svg"], "foreignObject"),
317317
(namespaces["svg"], "desc"),
318318
(namespaces["svg"], "title"),
319-
))
319+
])
320320

321-
formattingElements = frozenset((
321+
formattingElements = frozenset([
322322
(namespaces["html"], "a"),
323323
(namespaces["html"], "b"),
324324
(namespaces["html"], "big"),
@@ -333,9 +333,9 @@
333333
(namespaces["html"], "strong"),
334334
(namespaces["html"], "tt"),
335335
(namespaces["html"], "u")
336-
))
336+
])
337337

338-
specialElements = frozenset((
338+
specialElements = frozenset([
339339
(namespaces["html"], "address"),
340340
(namespaces["html"], "applet"),
341341
(namespaces["html"], "area"),
@@ -416,22 +416,22 @@
416416
(namespaces["html"], "wbr"),
417417
(namespaces["html"], "xmp"),
418418
(namespaces["svg"], "foreignObject")
419-
))
419+
])
420420

421-
htmlIntegrationPointElements = frozenset((
421+
htmlIntegrationPointElements = frozenset([
422422
(namespaces["mathml"], "annotaion-xml"),
423423
(namespaces["svg"], "foreignObject"),
424424
(namespaces["svg"], "desc"),
425425
(namespaces["svg"], "title")
426-
))
426+
])
427427

428-
mathmlTextIntegrationPointElements = frozenset((
428+
mathmlTextIntegrationPointElements = frozenset([
429429
(namespaces["mathml"], "mi"),
430430
(namespaces["mathml"], "mo"),
431431
(namespaces["mathml"], "mn"),
432432
(namespaces["mathml"], "ms"),
433433
(namespaces["mathml"], "mtext")
434-
))
434+
])
435435

436436
adjustForeignAttributes = {
437437
"xlink:actuate": ("xlink", "actuate", namespaces["xlink"]),
@@ -451,21 +451,21 @@
451451
unadjustForeignAttributes = dict([((ns, local), qname) for qname, (prefix, local, ns) in
452452
adjustForeignAttributes.items()])
453453

454-
spaceCharacters = frozenset((
454+
spaceCharacters = frozenset([
455455
"\t",
456456
"\n",
457457
"\u000C",
458458
" ",
459459
"\r"
460-
))
460+
])
461461

462-
tableInsertModeElements = frozenset((
462+
tableInsertModeElements = frozenset([
463463
"table",
464464
"tbody",
465465
"tfoot",
466466
"thead",
467467
"tr"
468-
))
468+
])
469469

470470
asciiLowercase = frozenset(string.ascii_lowercase)
471471
asciiUppercase = frozenset(string.ascii_uppercase)
@@ -486,7 +486,7 @@
486486
"h6"
487487
)
488488

489-
voidElements = frozenset((
489+
voidElements = frozenset([
490490
"base",
491491
"command",
492492
"event-source",
@@ -502,39 +502,39 @@
502502
"input",
503503
"source",
504504
"track"
505-
))
505+
])
506506

507-
cdataElements = frozenset(('title', 'textarea'))
507+
cdataElements = frozenset(['title', 'textarea'])
508508

509-
rcdataElements = frozenset((
509+
rcdataElements = frozenset([
510510
'style',
511511
'script',
512512
'xmp',
513513
'iframe',
514514
'noembed',
515515
'noframes',
516516
'noscript'
517-
))
517+
])
518518

519519
booleanAttributes = {
520-
"": frozenset(("irrelevant",)),
521-
"style": frozenset(("scoped",)),
522-
"img": frozenset(("ismap",)),
523-
"audio": frozenset(("autoplay", "controls")),
524-
"video": frozenset(("autoplay", "controls")),
525-
"script": frozenset(("defer", "async")),
526-
"details": frozenset(("open",)),
527-
"datagrid": frozenset(("multiple", "disabled")),
528-
"command": frozenset(("hidden", "disabled", "checked", "default")),
529-
"hr": frozenset(("noshade")),
530-
"menu": frozenset(("autosubmit",)),
531-
"fieldset": frozenset(("disabled", "readonly")),
532-
"option": frozenset(("disabled", "readonly", "selected")),
533-
"optgroup": frozenset(("disabled", "readonly")),
534-
"button": frozenset(("disabled", "autofocus")),
535-
"input": frozenset(("disabled", "readonly", "required", "autofocus", "checked", "ismap")),
536-
"select": frozenset(("disabled", "readonly", "autofocus", "multiple")),
537-
"output": frozenset(("disabled", "readonly")),
520+
"": frozenset(["irrelevant"]),
521+
"style": frozenset(["scoped"]),
522+
"img": frozenset(["ismap"]),
523+
"audio": frozenset(["autoplay", "controls"]),
524+
"video": frozenset(["autoplay", "controls"]),
525+
"script": frozenset(["defer", "async"]),
526+
"details": frozenset(["open"]),
527+
"datagrid": frozenset(["multiple", "disabled"]),
528+
"command": frozenset(["hidden", "disabled", "checked", "default"]),
529+
"hr": frozenset(["noshade"]),
530+
"menu": frozenset(["autosubmit"]),
531+
"fieldset": frozenset(["disabled", "readonly"]),
532+
"option": frozenset(["disabled", "readonly", "selected"]),
533+
"optgroup": frozenset(["disabled", "readonly"]),
534+
"button": frozenset(["disabled", "autofocus"]),
535+
"input": frozenset(["disabled", "readonly", "required", "autofocus", "checked", "ismap"]),
536+
"select": frozenset(["disabled", "readonly", "autofocus", "multiple"]),
537+
"output": frozenset(["disabled", "readonly"]),
538538
}
539539

540540
# entitiesWindows1252 has to be _ordered_ and needs to have an index. It
@@ -574,7 +574,7 @@
574574
376 # 0x9F 0x0178 LATIN CAPITAL LETTER Y WITH DIAERESIS
575575
)
576576

577-
xmlEntities = frozenset(('lt;', 'gt;', 'amp;', 'apos;', 'quot;'))
577+
xmlEntities = frozenset(['lt;', 'gt;', 'amp;', 'apos;', 'quot;'])
578578

579579
entities = {
580580
"AElig": "\xc6",
@@ -3088,8 +3088,8 @@
30883088
"ParseError": 7
30893089
}
30903090

3091-
tagTokenTypes = frozenset((tokenTypes["StartTag"], tokenTypes["EndTag"],
3092-
tokenTypes["EmptyTag"]))
3091+
tagTokenTypes = frozenset([tokenTypes["StartTag"], tokenTypes["EndTag"],
3092+
tokenTypes["EmptyTag"]])
30933093

30943094

30953095
prefixes = dict([(v, k) for k, v in namespaces.items()])

0 commit comments

Comments
 (0)