Skip to content
Myr

Merge pull request #3242 from cslecrone/3211-ssl-import

Before adoption: this commit came in with the history the project adopted, so no landing records it.

"#3211: Don't require ssl module"

authored by David Lord · committed by GitHub · parents 6e995f2, 1718f19 · Browse files · 3 files+21 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+21 added−1 removed

  • tests:+6 added−0 removed
  • other:+15 added−1 removed

3 files+21 added−1 removed

modified:flask/cli.py+12 added-1 removed
14 unmodified lines
15import inspect16import os17import platform18import re19import ssl19import sys20import traceback21from functools import update_wrapper22from operator import attrgetter
11 unmodified lines
34 import dotenv35except ImportError:36 dotenv = None3738try:39 import ssl40except ImportError:41 ssl = None424344class NoAppException(click.UsageError):45 """Raised if an application cannot be found or loaded."""4647
639 unmodified lines
687 def __init__(self):688 self.path_type = click.Path(exists=True, dir_okay=False, resolve_path=True)689690 def convert(self, value, param, ctx):691 if ssl is None:692 raise click.BadParameter(693 'Using "--cert" requires Python to be compiled with SSL support.',694 ctx,695 param,696 )697698 try:699 return self.path_type(value, param, ctx)700 except click.BadParameter:701 value = click.STRING(value, param, ctx).lower()
262 unmodified lines
modified:tests/test_cli.py+6 added
609 unmodified lines
610 with pytest.raises(click.BadParameter):611 run_command.make_context("run", ["--cert", "ssl_context", "--key", __file__])612613614def test_run_cert_no_ssl(monkeypatch):615 monkeypatch.setattr("flask.cli.ssl", None)616 with pytest.raises(click.BadParameter):617 run_command.make_context("run", ["--cert", "not_here"])618619620def test_cli_blueprints(app):621 """Test blueprint commands register correctly to the application"""622 custom = Blueprint("custom", __name__, cli_group="customized")623 nested = Blueprint("nested", __name__)
46 unmodified lines
modified:CHANGES.rst+3 added
66 unmodified lines
67- Show a better error message when the view return type is not68 supported. :issue:`3214`69- ``flask.testing.make_test_environ_builder()`` has been deprecated in70 favour of a new class ``flask.testing.EnvironBuilder``. :pr:`3232`71- The ``flask run`` command no longer fails if Python is not built72 with SSL support. Using the ``--cert`` option will show an73 appropriate error message. :issue:`3211`7475.. _#2935: https://github.com/pallets/flask/issues/293576.. _#2957: https://github.com/pallets/flask/issues/295777.. _#2994: https://github.com/pallets/flask/pull/2994
947 unmodified lines