File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,6 +144,11 @@ def _uninstall_helper(*, verbosity=0):
144144
145145
146146def _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 (
Original file line number Diff line number Diff 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
286293EXPECTED_VERSION_OUTPUT = "pip " + ensurepip ._PIP_VERSION
287294
288295class 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 ):
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ Core and Builtins
2222Library
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
You can’t perform that action at this time.
0 commit comments