Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2df5cf

Browse files
committed
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
1 parent b7bb675 commit e2df5cf

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lib/ensurepip/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ def _uninstall_helper(*, verbosity=0):
144144

145145

146146
def _main(argv=None):
147+
if ssl is None:
148+
print("Ignoring ensurepip failure: {}".format(_MISSING_SSL_MESSAGE),
149+
file=sys.stderr)
150+
return
151+
147152
import argparse
148153
parser = argparse.ArgumentParser(prog="python -m ensurepip")
149154
parser.add_argument(

Lib/test/test_ensurepip.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,20 @@ def test_uninstall_requires_ssl(self):
281281
self.run_pip.assert_not_called()
282282
self.assertIn("PIP_THIS_SHOULD_STAY", self.os_environ)
283283

284+
def test_main_exits_early_with_warning(self):
285+
with test.support.captured_stderr() as stderr:
286+
ensurepip_no_ssl._main(["--version"])
287+
warning = stderr.getvalue().strip()
288+
self.assertTrue(warning.endswith("requires SSL/TLS"), warning)
289+
self.run_pip.assert_not_called()
290+
284291
# Basic testing of the main functions and their argument parsing
285292

286293
EXPECTED_VERSION_OUTPUT = "pip " + ensurepip._PIP_VERSION
287294

288295
class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
289296

297+
@requires_usable_pip
290298
def test_bootstrap_version(self):
291299
with test.support.captured_stdout() as stdout:
292300
with self.assertRaises(SystemExit):

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Core and Builtins
2222
Library
2323
-------
2424

25+
- Issue #19744: the ensurepip installation step now just prints a warning to
26+
stderr rather than failing outright if SSL/TLS is unavailable. This allows
27+
local installation of POSIX builds without SSL/TLS support.
28+
2529
- Issue #6815: os.path.expandvars() now supports non-ASCII environment
2630
variables names and values.
2731

0 commit comments

Comments
 (0)