Skip to content

Commit 677e4e8

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 365c1dc commit 677e4e8

16 files changed

+177
-15
lines changed

bleach/_vendor/01_html5lib_six.patch

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
diff --git bleach/_vendor/html5lib/_inputstream.py bleach/_vendor/html5lib/_inputstream.py
2+
index 0207dd2..0976251 100644
3+
--- bleach/_vendor/html5lib/_inputstream.py
4+
+++ bleach/_vendor/html5lib/_inputstream.py
5+
@@ -1,7 +1,7 @@
6+
from __future__ import absolute_import, division, unicode_literals
7+
8+
-from six import text_type
9+
-from six.moves import http_client, urllib
10+
+from bleach.six_shim import text_type
11+
+from bleach.six_shim import http_client, urllib
12+
13+
import codecs
14+
import re
15+
diff --git bleach/_vendor/html5lib/_tokenizer.py bleach/_vendor/html5lib/_tokenizer.py
16+
index 4748a19..d884801 100644
17+
--- bleach/_vendor/html5lib/_tokenizer.py
18+
+++ bleach/_vendor/html5lib/_tokenizer.py
19+
@@ -1,6 +1,6 @@
20+
from __future__ import absolute_import, division, unicode_literals
21+
22+
-from six import unichr as chr
23+
+from bleach.six_shim import unichr as chr
24+
25+
from collections import deque, OrderedDict
26+
from sys import version_info
27+
diff --git bleach/_vendor/html5lib/_trie/py.py bleach/_vendor/html5lib/_trie/py.py
28+
index c2ba3da..56f66bd 100644
29+
--- bleach/_vendor/html5lib/_trie/py.py
30+
+++ bleach/_vendor/html5lib/_trie/py.py
31+
@@ -1,5 +1,5 @@
32+
from __future__ import absolute_import, division, unicode_literals
33+
-from six import text_type
34+
+from bleach.six_shim import text_type
35+
36+
from bisect import bisect_left
37+
38+
diff --git bleach/_vendor/html5lib/_utils.py bleach/_vendor/html5lib/_utils.py
39+
index 9ea5794..635bb02 100644
40+
--- bleach/_vendor/html5lib/_utils.py
41+
+++ bleach/_vendor/html5lib/_utils.py
42+
@@ -7,7 +7,7 @@ try:
43+
except ImportError:
44+
from collections import Mapping
45+
46+
-from six import text_type, PY3
47+
+from bleach.six_shim import text_type, PY3
48+
49+
if PY3:
50+
import xml.etree.ElementTree as default_etree
51+
diff --git bleach/_vendor/html5lib/filters/lint.py bleach/_vendor/html5lib/filters/lint.py
52+
index acd4d7a..1340d97 100644
53+
--- bleach/_vendor/html5lib/filters/lint.py
54+
+++ bleach/_vendor/html5lib/filters/lint.py
55+
@@ -1,6 +1,6 @@
56+
from __future__ import absolute_import, division, unicode_literals
57+
58+
-from six import text_type
59+
+from bleach.six_shim import text_type
60+
61+
from . import base
62+
from ..constants import namespaces, voidElements
63+
diff --git bleach/_vendor/html5lib/filters/sanitizer.py bleach/_vendor/html5lib/filters/sanitizer.py
64+
index 70ef906..5c31e97 100644
65+
--- bleach/_vendor/html5lib/filters/sanitizer.py
66+
+++ bleach/_vendor/html5lib/filters/sanitizer.py
67+
@@ -12,7 +12,7 @@ import re
68+
import warnings
69+
from xml.sax.saxutils import escape, unescape
70+
71+
-from six.moves import urllib_parse as urlparse
72+
+from bleach.six_shim import urllib_parse as urlparse
73+
74+
from . import base
75+
from ..constants import namespaces, prefixes
76+
diff --git bleach/_vendor/html5lib/html5parser.py bleach/_vendor/html5lib/html5parser.py
77+
index 74d829d..b90a9fe 100644
78+
--- bleach/_vendor/html5lib/html5parser.py
79+
+++ bleach/_vendor/html5lib/html5parser.py
80+
@@ -1,5 +1,5 @@
81+
from __future__ import absolute_import, division, unicode_literals
82+
-from six import with_metaclass, viewkeys
83+
+from bleach.six_shim import with_metaclass, viewkeys
84+
85+
import types
86+
87+
diff --git bleach/_vendor/html5lib/serializer.py bleach/_vendor/html5lib/serializer.py
88+
index c66df68..5666f49 100644
89+
--- bleach/_vendor/html5lib/serializer.py
90+
+++ bleach/_vendor/html5lib/serializer.py
91+
@@ -1,5 +1,5 @@
92+
from __future__ import absolute_import, division, unicode_literals
93+
-from six import text_type
94+
+from bleach.six_shim import text_type
95+
96+
import re
97+
98+
diff --git bleach/_vendor/html5lib/treebuilders/base.py bleach/_vendor/html5lib/treebuilders/base.py
99+
index e4a3d71..2869da0 100644
100+
--- bleach/_vendor/html5lib/treebuilders/base.py
101+
+++ bleach/_vendor/html5lib/treebuilders/base.py
102+
@@ -1,5 +1,5 @@
103+
from __future__ import absolute_import, division, unicode_literals
104+
-from six import text_type
105+
+from bleach.six_shim import text_type
106+
107+
from ..constants import scopingElements, tableInsertModeElements, namespaces
108+
109+
diff --git bleach/_vendor/html5lib/treebuilders/etree.py bleach/_vendor/html5lib/treebuilders/etree.py
110+
index 086bed4..5ccfc4d 100644
111+
--- bleach/_vendor/html5lib/treebuilders/etree.py
112+
+++ bleach/_vendor/html5lib/treebuilders/etree.py
113+
@@ -1,7 +1,7 @@
114+
from __future__ import absolute_import, division, unicode_literals
115+
# pylint:disable=protected-access
116+
117+
-from six import text_type
118+
+from bleach.six_shim import text_type
119+
120+
import re
121+
122+
diff --git bleach/_vendor/html5lib/treebuilders/etree_lxml.py bleach/_vendor/html5lib/treebuilders/etree_lxml.py
123+
index e73de61..f462232 100644
124+
--- bleach/_vendor/html5lib/treebuilders/etree_lxml.py
125+
+++ bleach/_vendor/html5lib/treebuilders/etree_lxml.py
126+
@@ -28,7 +28,7 @@ from . import etree as etree_builders
127+
from .. import _ihatexml
128+
129+
import lxml.etree as etree
130+
-from six import PY3, binary_type
131+
+from bleach.six_shim import PY3, binary_type
132+
133+
134+
fullTree = True
135+
diff --git bleach/_vendor/html5lib/treewalkers/etree.py bleach/_vendor/html5lib/treewalkers/etree.py
136+
index 4465337..a9d9450 100644
137+
--- bleach/_vendor/html5lib/treewalkers/etree.py
138+
+++ bleach/_vendor/html5lib/treewalkers/etree.py
139+
@@ -3,7 +3,7 @@ from __future__ import absolute_import, division, unicode_literals
140+
from collections import OrderedDict
141+
import re
142+
143+
-from six import string_types
144+
+from bleach.six_shim import string_types
145+
146+
from . import base
147+
from .._utils import moduleFactoryFactory
148+
diff --git bleach/_vendor/html5lib/treewalkers/etree_lxml.py bleach/_vendor/html5lib/treewalkers/etree_lxml.py
149+
index a614ac5..ef42163 100644
150+
--- bleach/_vendor/html5lib/treewalkers/etree_lxml.py
151+
+++ bleach/_vendor/html5lib/treewalkers/etree_lxml.py
152+
@@ -1,5 +1,5 @@
153+
from __future__ import absolute_import, division, unicode_literals
154+
-from six import text_type
155+
+from bleach.six_shim import text_type
156+
157+
from collections import OrderedDict
158+

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

+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 with_metaclass, viewkeys
2+
from bleach.six_shim import with_metaclass, viewkeys
33

44
import types
55

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

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ BLEACH_VENDOR_DIR=${BLEACH_VENDOR_DIR:-"."}
88
DEST=${DEST:-"."}
99

1010
pip install --no-binary all --no-compile --no-deps -r "${BLEACH_VENDOR_DIR}/vendor.txt" --target "${DEST}"
11+
(cd "${DEST}" && patch -p2 < 01_html5lib_six.patch)
1112

1213
# install Python 3.6.14 urllib.urlparse for #536
1314
curl --proto '=https' --tlsv1.2 -o "${DEST}/parse.py" https://raw.githubusercontent.com/python/cpython/v3.6.14/Lib/urllib/parse.py

scripts/vendor_verify.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ 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
21-
BLEACH_VENDOR_DIR=bleach/_vendor DEST="${DEST}" bleach/_vendor/vendor_install.sh
24+
BLEACH_VENDOR_DIR="bleach/_vendor" DEST="${DEST}" bleach/_vendor/vendor_install.sh
2225

2326
# Diff contents of temp directory and bleach/_vendor/ excluding vendoring
2427
# infrastructure

0 commit comments

Comments
 (0)