Skip to content

Drop support for EOL Python 2.7, 3.5 and 3.6 #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Upgrade Python syntax for Python 3.7+
  • Loading branch information
hugovk committed Jul 6, 2022
commit 67b42b705cdb129e5833f113914764aaecc9e34b
10 changes: 2 additions & 8 deletions html5lib/_tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import deque, OrderedDict
from sys import version_info
from collections import deque

from .constants import spaceCharacters
from .constants import entities
Expand All @@ -14,11 +13,6 @@

entitiesTrie = Trie(entities)

if version_info >= (3, 7):
attributeMap = dict
else:
attributeMap = OrderedDict


class HTMLTokenizer:
""" This class takes care of tokenizing HTML.
Expand Down Expand Up @@ -232,7 +226,7 @@ def emitCurrentToken(self):
token["name"] = token["name"].translate(asciiUpper2Lower)
if token["type"] == tokenTypes["StartTag"]:
raw = token["data"]
data = attributeMap(raw)
data = dict(raw)
if len(raw) > len(data):
# we had some duplicated attribute, fix so first wins
data.update(raw[::-1])
Expand Down
9 changes: 4 additions & 5 deletions html5lib/tests/test_treewalkers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itertools
import sys

import pytest

Expand Down Expand Up @@ -139,8 +138,8 @@ def test_lxml_xml():
@pytest.mark.parametrize("treeName",
[pytest.param(treeName, marks=[getattr(pytest.mark, treeName),
pytest.mark.skipif(
treeName != "lxml" or
sys.version_info < (3, 7), reason="dict order undef")])
treeName != "lxml",
reason="dict order undef")])
for treeName in sorted(treeTypes.keys())])
def test_maintain_attribute_order(treeName):
treeAPIs = treeTypes[treeName]
Expand Down Expand Up @@ -172,8 +171,8 @@ def test_maintain_attribute_order(treeName):
@pytest.mark.parametrize("treeName",
[pytest.param(treeName, marks=[getattr(pytest.mark, treeName),
pytest.mark.skipif(
treeName != "lxml" or
sys.version_info < (3, 7), reason="dict order undef")])
treeName != "lxml",
reason="dict order undef")])
for treeName in sorted(treeTypes.keys())])
def test_maintain_attribute_order_adjusted(treeName):
treeAPIs = treeTypes[treeName]
Expand Down