[Python-apps-team] Bug#635496: cannot import mercurial.httpclient with Python 2.7: 'module' object has no attribute 'PROTOCOL_SSLv2'

Jonathan Nieder jrnieder at gmail.com
Tue Jul 26 13:46:24 UTC 2011


Hi,

Jakub Wilk wrote:

> $ python2.7 -c 'import mercurial.httpclient'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "/usr/lib/pymodules/python2.7/mercurial/httpclient/__init__.py", line 48, in <module>
>     import socketutil
>   File "/usr/lib/pymodules/python2.7/mercurial/httpclient/socketutil.py", line 81, in <module>
>     PROTOCOL_SSLv2 = ssl.PROTOCOL_SSLv2
> AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv2'

Yep.  Also:

 $ python2.6
[...]
 >>> import ssl
 >>> ssl.PROTOCOL_SSLv2
 0
 >>> ^D
 $ python2.7
 Python 2.7.2+ (default, Jul  9 2011, 12:34:36) 
 [GCC 4.6.1] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import ssl
 >>> ssl.PROTOCOL_SSLv2
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv2'
 >>> help(ssl)
 Help on module ssl:
[...]
     The following constants identify various SSL protocol variants:

     PROTOCOL_SSLv2
     PROTOCOL_SSLv3
     PROTOCOL_SSLv23
     PROTOCOL_TLSv1

And:

 $ cat /usr/lib/python2.7/ssl.py
 [...]
 from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
 _PROTOCOL_NAMES = {
     PROTOCOL_TLSv1: "TLSv1",
     PROTOCOL_SSLv23: "SSLv23",
     PROTOCOL_SSLv3: "SSLv3",
 }
 try:
     from _ssl import PROTOCOL_SSLv2
 except ImportError:
     pass
 else:
     _PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"

Conclusions:

 * mercurial should probably stop defining a PROTOCOL_SSLv2
   constant it doesn't need. :)

 * The docstring for the ssl module should probably not mention the
   missing symbol.

 * Other packages might be affected as well.  Would it make sense to
   mention in python2.7's NEWS.Debian.gz that the ssl.PROTOCOL_SSLv2
   symbol has been removed?

Thanks for reporting,
Jonathan





More information about the Python-apps-team mailing list