Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'module' object has no attribute 'SSLContext' #2789

Conversation

briehanlombaard
Copy link
Contributor

We're still using Python 2.7.6 for some projects which causes the exception listed below when trying to execute flask run. The problem appears to be when the run command executes flask.cli._validate_key which then checks for Python version 2.7 or above before attempting to access ssl.SSLContext. The problem with that is that SSLContext was only added in 2.7.9 so the check needs to be more exact by checking for versions 2.7.9 and above.

Relevant tests already fail under Python 2.7.6 and have been updated so this patch doesn't require any additional tests as far as I can tell. Let me know if that is not the case.

Traceback (most recent call last):
  File "/usr/local/bin/flask", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/flask/cli.py", line 894, in main
    cli.main(args=args, prog_name=name)
  File "/usr/local/lib/python2.7/dist-packages/flask/cli.py", line 557, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1064, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)  
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 621, in make_context
    self.parse_args(ctx, args)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 880, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1404, in handle_parse_result
    self.callback, ctx, self, value)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 78, in invoke_param_callback
    return callback(ctx, param, value)
  File "/usr/local/lib/python2.7/dist-packages/flask/cli.py", line 693, in _validate_key
    is_context = isinstance(cert, ssl.SSLContext)
AttributeError: 'module' object has no attribute 'SSLContext'

Version information:

$ flask --version
Flask 1.0.2
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2]

tests/test_cli.py Outdated Show resolved Hide resolved
@davidism
Copy link
Member

They added a whole feature in a point release?!

@ThiefMaster
Copy link
Member

@davidism davidism changed the base branch from master to 1.0-maintenance May 17, 2018 13:19
@davidism davidism force-pushed the fix-sslcontext-attribute-error branch from 0d3f0aa to a913b4d Compare May 17, 2018 13:19
@davidism davidism added this to the 1.0.3 milestone May 17, 2018
@davidism davidism merged commit 401d7f9 into pallets:1.0-maintenance May 17, 2018
@davidism davidism mentioned this pull request May 23, 2018
@kinow kinow mentioned this pull request Sep 6, 2018
6 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants