summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-02-15 09:14:54 +1000
committerNick Coghlan <ncoghlan@gmail.com>2014-02-15 09:14:54 +1000
commite2df5cfcbd37ca88a9826c2e1647ac09964beb33 (patch)
treebd04d3ef77a029572d935796954ad18097d23abc /Lib
parentb7bb675d3c034c3a46cc485352bbb035f74f47ff (diff)
downloadcpython-git-e2df5cfcbd37ca88a9826c2e1647ac09964beb33.tar.gz
Issue #19744: Handle missing SSL/TLS in ensurepip
- now also allows POSIX installation with SSL/TLS missing - a goal for pip 1.6 is to allow local use without SSL/TLS
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ensurepip/__init__.py5
-rw-r--r--Lib/test/test_ensurepip.py8
2 files changed, 13 insertions, 0 deletions
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index e8d6abeb1f..3f4e449cbc 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -144,6 +144,11 @@ def _uninstall_helper(*, verbosity=0):
def _main(argv=None):
+ if ssl is None:
+ print("Ignoring ensurepip failure: {}".format(_MISSING_SSL_MESSAGE),
+ file=sys.stderr)
+ return
+
import argparse
parser = argparse.ArgumentParser(prog="python -m ensurepip")
parser.add_argument(
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
index 6ddf8f6563..8644a651bb 100644
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -281,12 +281,20 @@ class TestMissingSSL(EnsurepipMixin, unittest.TestCase):
self.run_pip.assert_not_called()
self.assertIn("PIP_THIS_SHOULD_STAY", self.os_environ)
+ def test_main_exits_early_with_warning(self):
+ with test.support.captured_stderr() as stderr:
+ ensurepip_no_ssl._main(["--version"])
+ warning = stderr.getvalue().strip()
+ self.assertTrue(warning.endswith("requires SSL/TLS"), warning)
+ self.run_pip.assert_not_called()
+
# Basic testing of the main functions and their argument parsing
EXPECTED_VERSION_OUTPUT = "pip " + ensurepip._PIP_VERSION
class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
+ @requires_usable_pip
def test_bootstrap_version(self):
with test.support.captured_stdout() as stdout:
with self.assertRaises(SystemExit):