Skip to content

Commit ef7ca14

Browse files
committed
Add an html5lib patch for Python 3.9 compatibility
The patch is adapted from html5lib/html5lib-python@4f92357 Closes #6407 Closes #6237
1 parent a53e571 commit ef7ca14

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

news/6728.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make vendored html5lib compatible with Python 3.9.

src/pip/_vendor/html5lib/_trie/_base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3-
from collections import Mapping
3+
try:
4+
from collections.abc import Mapping
5+
except ImportError: # Python 2.7
6+
from collections import Mapping
47

58

69
class Trie(Mapping):

src/pip/_vendor/html5lib/treebuilders/dom.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import absolute_import, division, unicode_literals
22

33

4-
from collections import MutableMapping
4+
try:
5+
from collections.abc import MutableMapping
6+
except ImportError: # Python 2.7
7+
from collections import MutableMapping
58
from xml.dom import minidom, Node
69
import weakref
710

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/src/pip/_vendor/html5lib/_trie/_base.py b/src/pip/_vendor/html5lib/_trie/_base.py
2+
index a1158bbb..6b71975f 100644
3+
--- a/src/pip/_vendor/html5lib/_trie/_base.py
4+
+++ b/src/pip/_vendor/html5lib/_trie/_base.py
5+
@@ -1,6 +1,9 @@
6+
from __future__ import absolute_import, division, unicode_literals
7+
8+
-from collections import Mapping
9+
+try:
10+
+ from collections.abc import Mapping
11+
+except ImportError: # Python 2.7
12+
+ from collections import Mapping
13+
14+
15+
class Trie(Mapping):
16+
diff --git a/src/pip/_vendor/html5lib/treebuilders/dom.py b/src/pip/_vendor/html5lib/treebuilders/dom.py
17+
index dcfac220..d8b53004 100644
18+
--- a/src/pip/_vendor/html5lib/treebuilders/dom.py
19+
+++ b/src/pip/_vendor/html5lib/treebuilders/dom.py
20+
@@ -1,7 +1,10 @@
21+
from __future__ import absolute_import, division, unicode_literals
22+
23+
24+
-from collections import MutableMapping
25+
+try:
26+
+ from collections.abc import MutableMapping
27+
+except ImportError: # Python 2.7
28+
+ from collections import MutableMapping
29+
from xml.dom import minidom, Node
30+
import weakref
31+

0 commit comments

Comments
 (0)