[Python-checkins] cpython (3.4): Close #20757: return success for skipped pip uninstall

larry.hastings python-checkins at python.org
Mon Mar 17 07:33:06 CET 2014


http://hg.python.org/cpython/rev/6d0994805e18
changeset:   89775:6d0994805e18
branch:      3.4
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Fri Feb 28 23:35:05 2014 +1000
summary:
  Close #20757: return success for skipped pip uninstall

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.

files:
  Lib/ensurepip/__init__.py  |   5 +++--
  Lib/test/test_ensurepip.py |   6 ++++--
  Misc/NEWS                  |  14 ++++++++++++++
  3 files changed, 21 insertions(+), 4 deletions(-)


diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -128,9 +128,10 @@
 
     # 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()
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -196,10 +196,12 @@
             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()
 
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,6 +2,20 @@
 Python News
 +++++++++++
 
+What's New in Python 3.4.0 release candidate 3?
+===============================================
+
+Release date: 2014-03-09
+
+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.
+
+
+
 What's New in Python 3.4.0 release candidate 2?
 ===============================================
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list