Merge pull request #8278 from tiran/py3_celementtree

This commit is contained in:
Pradyun Gedam 2020-05-30 17:07:10 +05:30 committed by GitHub
commit d01bfcfaa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 6 deletions

1
news/8278.vendor Normal file
View File

@ -0,0 +1 @@
Vendored htmlib5 no longer imports deprecated xml.etree.cElementTree on Python 3.

View File

@ -100,8 +100,9 @@ Modifications
* ``setuptools`` is completely stripped to only keep ``pkg_resources``
* ``pkg_resources`` has been modified to import its dependencies from ``pip._vendor``
* ``packaging`` has been modified to import its dependencies from ``pip._vendor``
* ``html5lib`` has been modified to import six from ``pip._vendor`` and
to prefer importing from ``collections.abc`` instead of ``collections``.
* ``html5lib`` has been modified to import six from ``pip._vendor``, to prefer
importing from ``collections.abc`` instead of ``collections`` and does not import
``xml.etree.cElementTree`` on Python 3.
* ``CacheControl`` has been modified to import its dependencies from ``pip._vendor``
* ``requests`` has been modified to import its other dependencies from ``pip._vendor``
and to *not* load ``simplejson`` (all platforms) and ``pyopenssl`` (Windows).

View File

@ -2,12 +2,15 @@ from __future__ import absolute_import, division, unicode_literals
from types import ModuleType
from pip._vendor.six import text_type
from pip._vendor.six import text_type, PY3
try:
import xml.etree.cElementTree as default_etree
except ImportError:
if PY3:
import xml.etree.ElementTree as default_etree
else:
try:
import xml.etree.cElementTree as default_etree
except ImportError:
import xml.etree.ElementTree as default_etree
__all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",

View File

@ -28,4 +28,28 @@ index dcfac220..d8b53004 100644
+ from collections import MutableMapping
from xml.dom import minidom, Node
import weakref
diff --git a/src/pip/_vendor/html5lib/_utils.py b/src/pip/_vendor/html5lib/_utils.py
index 0703afb3..96eb17b2 100644
--- a/src/pip/_vendor/html5lib/_utils.py
+++ b/src/pip/_vendor/html5lib/_utils.py
@@ -2,12 +2,15 @@ from __future__ import absolute_import, division, unicode_literals
from types import ModuleType
-from pip._vendor.six import text_type
+from pip._vendor.six import text_type, PY3
-try:
- import xml.etree.cElementTree as default_etree
-except ImportError:
+if PY3:
import xml.etree.ElementTree as default_etree
+else:
+ try:
+ import xml.etree.cElementTree as default_etree
+ except ImportError:
+ import xml.etree.ElementTree as default_etree
__all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",