diff --git a/CHANGES.rst b/CHANGES.rst index 82605a21..46670446 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,23 @@ Change Log ---------- +1.1 +~~~ + +UNRELEASED + +Breaking changes: + +* Drop support for Python 3.3. (#358) +* Drop support for Python 3.4. (#421) + +Other changes: + +* Try to import from `collections.abc` to remove DeprecationWarning and ensure + `html5lib` keeps working in future Python versions. (#403) +* Drop optional `datrie` dependency. (#442) + + 1.0.1 ~~~~~ diff --git a/README.rst b/README.rst index fb9398f6..cec41d71 100644 --- a/README.rst +++ b/README.rst @@ -107,9 +107,6 @@ Optional Dependencies The following third-party libraries may be used for additional functionality: -- ``datrie`` can be used under CPython to improve parsing performance - (though in almost all cases the improvement is marginal); - - ``lxml`` is supported as a tree format (for both building and walking) under CPython (but *not* PyPy where it is known to cause segfaults); diff --git a/debug-info.py b/debug-info.py index f93fbdbe..b47b8ebf 100644 --- a/debug-info.py +++ b/debug-info.py @@ -12,7 +12,7 @@ "maxsize": sys.maxsize } -search_modules = ["chardet", "datrie", "genshi", "html5lib", "lxml", "six"] +search_modules = ["chardet", "genshi", "html5lib", "lxml", "six"] found_modules = [] for m in search_modules: diff --git a/html5lib/_trie/__init__.py b/html5lib/_trie/__init__.py index a5ba4bf1..07bad5d3 100644 --- a/html5lib/_trie/__init__.py +++ b/html5lib/_trie/__init__.py @@ -1,14 +1,5 @@ from __future__ import absolute_import, division, unicode_literals -from .py import Trie as PyTrie +from .py import Trie -Trie = PyTrie - -# pylint:disable=wrong-import-position -try: - from .datrie import Trie as DATrie -except ImportError: - pass -else: - Trie = DATrie -# pylint:enable=wrong-import-position +__all__ = ["Trie"] diff --git a/html5lib/_trie/datrie.py b/html5lib/_trie/datrie.py deleted file mode 100644 index 51f3d046..00000000 --- a/html5lib/_trie/datrie.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import absolute_import, division, unicode_literals - -from datrie import Trie as DATrie -from six import text_type - -from ._base import Trie as ABCTrie - - -class Trie(ABCTrie): - def __init__(self, data): - chars = set() - for key in data.keys(): - if not isinstance(key, text_type): - raise TypeError("All keys must be strings") - for char in key: - chars.add(char) - - self._data = DATrie("".join(chars)) - for key, value in data.items(): - self._data[key] = value - - def __contains__(self, key): - return key in self._data - - def __len__(self): - return len(self._data) - - def __iter__(self): - raise NotImplementedError() - - def __getitem__(self, key): - return self._data[key] - - def keys(self, prefix=None): - return self._data.keys(prefix) - - def has_keys_with_prefix(self, prefix): - return self._data.has_keys_with_prefix(prefix) - - def longest_prefix(self, prefix): - return self._data.longest_prefix(prefix) - - def longest_prefix_item(self, prefix): - return self._data.longest_prefix_item(prefix) diff --git a/requirements-optional.txt b/requirements-optional.txt index d8be39ff..2e78c952 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -11,9 +11,3 @@ chardet>=2.2 # lxml is supported with its own treebuilder ("lxml") and otherwise # uses the standard ElementTree support lxml ; platform_python_implementation == 'CPython' - -# DATrie can be used in place of our Python trie implementation for -# slightly better parsing performance. -# https://github.com/pytries/datrie/issues/52 although closed is not -# yet released to https://pypi.org/project/datrie -datrie ; platform_python_implementation == 'CPython' and python_version < '3.7' diff --git a/setup.py b/setup.py index d3841290..f84c1284 100644 --- a/setup.py +++ b/setup.py @@ -111,7 +111,6 @@ def default_environment(): extras_require={ # A conditional extra will only install these items when the extra is # requested and the condition matches. - "datrie:platform_python_implementation == 'CPython'": ["datrie"], "lxml:platform_python_implementation == 'CPython'": ["lxml"], # Standard extras, will be installed when the extra is requested. @@ -123,6 +122,6 @@ def default_environment(): # extra that will be installed whenever the condition matches and the # all extra is requested. "all": ["genshi", "chardet>=2.2"], - "all:platform_python_implementation == 'CPython'": ["datrie", "lxml"], + "all:platform_python_implementation == 'CPython'": ["lxml"], }, )