]> granicus.if.org Git - python/commitdiff
bpo-37449: Move ensurepip off of pkgutil and to importlib.resources (GH-15109)
authorJoannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
Fri, 13 Sep 2019 16:01:20 +0000 (13:01 -0300)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 13 Sep 2019 16:01:20 +0000 (09:01 -0700)
Move ensurepip off of pkgutil and to importlib.resources.

https://bugs.python.org/issue37449

Lib/ensurepip/__init__.py
Lib/ensurepip/_bundled/__init__.py [new file with mode: 0644]
Misc/NEWS.d/next/Library/2019-08-04-17-22-33.bpo-37449.ycbL2z.rst [new file with mode: 0644]

index fc0edec6e3de6e9197e315a0b9fd1739257b2edf..386ed6c25c763efb8b9188a61f65a10c5f626f6b 100644 (file)
@@ -1,8 +1,11 @@
 import os
 import os.path
-import pkgutil
 import sys
 import tempfile
+from importlib import resources
+
+from . import _bundled
+
 
 
 __all__ = ["version", "bootstrap"]
@@ -96,9 +99,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
         additional_paths = []
         for project, version in _PROJECTS:
             wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
-            whl = pkgutil.get_data(
-                "ensurepip",
-                "_bundled/{}".format(wheel_name),
+            whl = resources.read_binary(
+                _bundled,
+                wheel_name,
             )
             with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
                 fp.write(whl)
diff --git a/Lib/ensurepip/_bundled/__init__.py b/Lib/ensurepip/_bundled/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Misc/NEWS.d/next/Library/2019-08-04-17-22-33.bpo-37449.ycbL2z.rst b/Misc/NEWS.d/next/Library/2019-08-04-17-22-33.bpo-37449.ycbL2z.rst
new file mode 100644 (file)
index 0000000..b34bfea
--- /dev/null
@@ -0,0 +1,2 @@
+`ensurepip` now uses `importlib.resources.read_binary()` to read data instead of `pkgutil.get_data()`.\r
+Patch by Joannah Nanjekye.
\ No newline at end of file