Skip to content

Fix collections imports for Python 3.8 #408

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 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions html5lib/_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from six import unichr as chr

from collections import deque

from .constants import spaceCharacters
from .constants import entities
from .constants import asciiLetters, asciiUpper2Lower
Expand All @@ -15,6 +13,11 @@

from ._trie import Trie

try:
from collections.abc import deque
except ImportError:
from collections import deque

entitiesTrie = Trie(entities)


Expand Down
5 changes: 4 additions & 1 deletion html5lib/filters/alphabeticalattributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

from . import base

from collections import OrderedDict
try:
from collections.abc import OrderedDict
except ImportError:
from collections import OrderedDict


def _attr_key(attr):
Expand Down
6 changes: 5 additions & 1 deletion html5lib/html5parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from six import with_metaclass, viewkeys

import types
from collections import OrderedDict

from . import _inputstream
from . import _tokenizer
Expand All @@ -23,6 +22,11 @@
_ReparseException
)

try:
from collections.abc import OrderedDict
except ImportError:
from collections import OrderedDict


def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
"""Parse an HTML document as a string or file-like object into a tree
Expand Down
7 changes: 5 additions & 2 deletions html5lib/tests/test_alphabeticalattributes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import absolute_import, division, unicode_literals

from collections import OrderedDict

import pytest

import html5lib
from html5lib.filters.alphabeticalattributes import Filter
from html5lib.serializer import HTMLSerializer

try:
from collections.abc import OrderedDict
except ImportError:
from collections import OrderedDict


@pytest.mark.parametrize('msg, attrs, expected_attrs', [
(
Expand Down
6 changes: 5 additions & 1 deletion html5lib/treewalkers/etree.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from __future__ import absolute_import, division, unicode_literals

from collections import OrderedDict
import re

from six import string_types

from . import base
from .._utils import moduleFactoryFactory

try:
from collections.abc import OrderedDict
except ImportError:
from collections import OrderedDict

tag_regexp = re.compile("{([^}]*)}(.*)")


Expand Down