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

importing ssl can fail with NameError: name 'PROTOCOL_TLS' is not defined #73774

Closed
jdemeyer opened this issue Feb 17, 2017 · 2 comments
Closed
Assignees
Labels
topic-SSL type-bug An unexpected behavior, bug, or error

Comments

@jdemeyer
Copy link
Contributor

BPO 29588
Nosy @tiran, @jdemeyer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/tiran'
closed_at = <Date 2017-09-06.19:50:40.509>
created_at = <Date 2017-02-17.11:35:23.374>
labels = ['expert-SSL', 'type-bug']
title = "importing ssl can fail with NameError: name 'PROTOCOL_TLS' is not defined"
updated_at = <Date 2017-09-06.19:50:40.508>
user = 'https://github.com/jdemeyer'

bugs.python.org fields:

activity = <Date 2017-09-06.19:50:40.508>
actor = 'christian.heimes'
assignee = 'christian.heimes'
closed = True
closed_date = <Date 2017-09-06.19:50:40.509>
closer = 'christian.heimes'
components = ['SSL']
creation = <Date 2017-02-17.11:35:23.374>
creator = 'jdemeyer'
dependencies = []
files = []
hgrepos = []
issue_num = 29588
keywords = []
message_count = 2.0
messages = ['287989', '287991']
nosy_count = 2.0
nosy_names = ['christian.heimes', 'jdemeyer']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue29588'
versions = ['Python 2.7']

@jdemeyer
Copy link
Contributor Author

This is a regression introduced in Python 2.7.13:

Importing the ssl module can fail with

>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jdemeyer/sage/local/lib/python/ssl.py", line 133, in <module>
    PROTOCOL_SSLv23 = PROTOCOL_TLS
NameError: name 'PROTOCOL_TLS' is not defined

While getting an ImportError from the ssl module is expected if SSL is not available (httplib for example handles that fine), a NameError is not.

@tiran
Copy link
Member

tiran commented Feb 17, 2017

The _ssl extension module always defines and exports PROTOCOL_TLS. The name is always available. I guess you somehow mixed a new ssl.py with an old _ssl.so. Please verify that _ssl is correct and defines the name.

@tiran tiran closed this as completed Sep 6, 2017
@tiran tiran added the type-bug An unexpected behavior, bug, or error label Sep 6, 2017
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-SSL type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants