]> granicus.if.org Git - python/commitdiff
Close #20757: return success for skipped pip uninstall
authorNick Coghlan <ncoghlan@gmail.com>
Fri, 28 Feb 2014 13:35:05 +0000 (23:35 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Fri, 28 Feb 2014 13:35:05 +0000 (23:35 +1000)
The 3.4rc2 Windows uninstaller would fail if pip had been updated
to a version that didn't match the version installed by ensurepip.
This skip is no longer treated as an error, so an updated pip ends
up being handled like any other pip installed package and is left
alone by the CPython uninstaller.

Lib/ensurepip/__init__.py
Lib/test/test_ensurepip.py
Misc/NEWS

index f584bdc4d18f8bfe4b74f0d89f8244572b555438..7cf6a4b82673694d4ffa7b0aa61041578c3e0ad1 100644 (file)
@@ -128,9 +128,10 @@ def _uninstall_helper(*, verbosity=0):
 
     # If the pip version doesn't match the bundled one, leave it alone
     if pip.__version__ != _PIP_VERSION:
-        msg = ("ensurepip will only uninstall a matching pip "
+        msg = ("ensurepip will only uninstall a matching version "
                "({!r} installed, {!r} bundled)")
-        raise RuntimeError(msg.format(pip.__version__, _PIP_VERSION))
+        print(msg.format(pip.__version__, _PIP_VERSION), file=sys.stderr)
+        return
 
     _require_ssl_for_pip()
     _disable_pip_configuration_settings()
index 8644a651bb11dc7d801bcd6df59ec4f6df9f7569..70b41538a39ff9fb695f9756ae7a98a4bd5373f7 100644 (file)
@@ -196,10 +196,12 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
             ensurepip._uninstall_helper()
         self.run_pip.assert_not_called()
 
-    def test_uninstall_fails_with_wrong_version(self):
+    def test_uninstall_skipped_with_warning_for_wrong_version(self):
         with fake_pip("not a valid version"):
-            with self.assertRaises(RuntimeError):
+            with test.support.captured_stderr() as stderr:
                 ensurepip._uninstall_helper()
+        warning = stderr.getvalue().strip()
+        self.assertIn("only uninstall a matching version", warning)
         self.run_pip.assert_not_called()
 
 
index 77b969cecfb13a09d4a810cab86bf0bce9654a55..291365d965f37bdd62903a14619581c0c3f2e49d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,13 @@ Tests
 
 - Issue #20743: Fix a reference leak in test_tcl.
 
+Build
+-----
+
+- Issue #20757: The ensurepip helper for the Windows uninstaller now skips
+  uninstalling pip (rather than failing) if the user has updated pip to a
+  different version from the one bundled with ensurepip.
+
 Tools/Demos
 -----------