Browse Source

Merge pull request #2789 from briehanlombaard/fix-sslcontext-attribute-error

AttributeError: 'module' object has no attribute 'SSLContext'
pull/2804/head
David Lord 7 years ago committed by GitHub
parent
commit
401d7f9bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      flask/cli.py
  2. 4
      tests/test_cli.py

4
flask/cli.py

@ -670,7 +670,7 @@ class CertParamType(click.ParamType):
obj = import_string(value, silent=True)
if sys.version_info < (2, 7):
if sys.version_info < (2, 7, 9):
if obj:
return obj
else:
@ -687,7 +687,7 @@ def _validate_key(ctx, param, value):
cert = ctx.params.get('cert')
is_adhoc = cert == 'adhoc'
if sys.version_info < (2, 7):
if sys.version_info < (2, 7, 9):
is_context = cert and not isinstance(cert, (text_type, bytes))
else:
is_context = isinstance(cert, ssl.SSLContext)

4
tests/test_cli.py

@ -521,12 +521,12 @@ def test_run_cert_import(monkeypatch):
run_command.make_context('run', ['--cert', 'not_here'])
# not an SSLContext
if sys.version_info >= (2, 7):
if sys.version_info >= (2, 7, 9):
with pytest.raises(click.BadParameter):
run_command.make_context('run', ['--cert', 'flask'])
# SSLContext
if sys.version_info < (2, 7):
if sys.version_info < (2, 7, 9):
ssl_context = object()
else:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)

Loading…
Cancel
Save