Skip to content

Commit 4783764

Browse files
committed
Remove six dependency from html5lib (#618)
This way lies madness, but at least we don't have a six dependency anymore. The way this work is that we vendored html5lib 1.1, but then this applies a 01_html5lib_six.patch to that which changes imports from six to import from bleach.six_shim. This updates the vendor management code and vendorverify to install html5lib 1.1 and then apply the patch and then compare with what's in the tree. If we end up applying further patches in the future, we can use this model to do that.
1 parent cf53a47 commit 4783764

15 files changed

+22
-15
lines changed

bleach/_vendor/html5lib/_inputstream.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3-
from six import text_type
4-
from six.moves import http_client, urllib
3+
from bleach.six_shim import text_type
4+
from bleach.six_shim import http_client, urllib
55

66
import codecs
77
import re

bleach/_vendor/html5lib/_tokenizer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3-
from six import unichr as chr
3+
from bleach.six_shim import unichr as chr
44

55
from collections import deque, OrderedDict
66
from sys import version_info

bleach/_vendor/html5lib/_trie/py.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import absolute_import, division, unicode_literals
2-
from six import text_type
2+
from bleach.six_shim import text_type
33

44
from bisect import bisect_left
55

bleach/_vendor/html5lib/_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
except ImportError:
88
from collections import Mapping
99

10-
from six import text_type, PY3
10+
from bleach.six_shim import text_type, PY3
1111

1212
if PY3:
1313
import xml.etree.ElementTree as default_etree

bleach/_vendor/html5lib/filters/lint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3-
from six import text_type
3+
from bleach.six_shim import text_type
44

55
from . import base
66
from ..constants import namespaces, voidElements

bleach/_vendor/html5lib/filters/sanitizer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313
from xml.sax.saxutils import escape, unescape
1414

15-
from six.moves import urllib_parse as urlparse
15+
from bleach.six_shim import urllib_parse as urlparse
1616

1717
from . import base
1818
from ..constants import namespaces, prefixes

bleach/_vendor/html5lib/html5parser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import absolute_import, division, unicode_literals
2-
from six import with_metaclass, viewkeys
2+
from bleach.six_shim import viewkeys
33

44
import types
55

@@ -423,7 +423,7 @@ def getMetaclass(use_metaclass, metaclass_func):
423423
return type
424424

425425
# pylint:disable=unused-argument
426-
class Phase(with_metaclass(getMetaclass(debug, log))):
426+
class Phase(metaclass=getMetaclass(debug, log)):
427427
"""Base class for helper object that implements each phase of processing
428428
"""
429429
__slots__ = ("parser", "tree", "__startTagCache", "__endTagCache")

bleach/_vendor/html5lib/serializer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import absolute_import, division, unicode_literals
2-
from six import text_type
2+
from bleach.six_shim import text_type
33

44
import re
55

bleach/_vendor/html5lib/treebuilders/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import absolute_import, division, unicode_literals
2-
from six import text_type
2+
from bleach.six_shim import text_type
33

44
from ..constants import scopingElements, tableInsertModeElements, namespaces
55

bleach/_vendor/html5lib/treebuilders/etree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import absolute_import, division, unicode_literals
22
# pylint:disable=protected-access
33

4-
from six import text_type
4+
from bleach.six_shim import text_type
55

66
import re
77

bleach/_vendor/html5lib/treebuilders/etree_lxml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from .. import _ihatexml
2929

3030
import lxml.etree as etree
31-
from six import PY3, binary_type
31+
from bleach.six_shim import PY3, binary_type
3232

3333

3434
fullTree = True

bleach/_vendor/html5lib/treewalkers/etree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections import OrderedDict
44
import re
55

6-
from six import string_types
6+
from bleach.six_shim import string_types
77

88
from . import base
99
from .._utils import moduleFactoryFactory

bleach/_vendor/html5lib/treewalkers/etree_lxml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import absolute_import, division, unicode_literals
2-
from six import text_type
2+
from bleach.six_shim import text_type
33

44
from collections import OrderedDict
55

bleach/_vendor/vendor_install.sh

+4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ set -o pipefail
77
BLEACH_VENDOR_DIR=${BLEACH_VENDOR_DIR:-"."}
88
DEST=${DEST:-"."}
99

10+
# Install with no dependencies
1011
pip install --no-binary all --no-compile --no-deps -r "${BLEACH_VENDOR_DIR}/vendor.txt" --target "${DEST}"
1112

13+
# Apply patches
14+
(cd "${DEST}" && patch -p2 < 01_html5lib_six.patch)
15+
1216
# install Python 3.6.14 urllib.urlparse for #536
1317
curl --proto '=https' --tlsv1.2 -o "${DEST}/parse.py" https://raw.githubusercontent.com/python/cpython/v3.6.14/Lib/urllib/parse.py
1418
(cd "${DEST}" && sha256sum parse.py > parse.py.SHA256SUM)

scripts/vendor_verify.sh

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ mkdir "${DEST}"
1717
# Get versions of pip and python
1818
pip --version
1919

20+
# Copy patch files to dest directory
21+
cp bleach/_vendor/*.patch "${DEST}"
22+
2023
# Install vendored dependencies into temp directory
2124
BLEACH_VENDOR_DIR=bleach/_vendor DEST="${DEST}" bleach/_vendor/vendor_install.sh
2225

0 commit comments

Comments
 (0)