classification
Title: importing ssl can fail with NameError: name 'PROTOCOL_TLS' is not defined
Type: Stage:
Components: SSL Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, jdemeyer
Priority: normal Keywords:

Created on 2017-02-17 11:35 by jdemeyer, last changed 2017-02-17 11:46 by christian.heimes.

Messages (2)
msg287989 - (view) Author: Jeroen Demeyer (jdemeyer) * Date: 2017-02-17 11:35
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.
msg287991 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-02-17 11:46
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.
History
Date User Action Args
2017-02-17 11:46:32christian.heimessetmessages: + msg287991
2017-02-17 11:35:23jdemeyercreate