Issue #1076 duplicate

Import error of HTTPSConnection is hidden by python3 compatibility.

guest
created an issue

It's a common problem that python won't have httplib.HTTPSConnection if it was built without ssl headers. But that import error will be caught in cherrypy._cpcompat.py even though python2 is being used. Instead the user will see this failure:

{{{ ImportError: No module named http.cookies) }}}

as if they were using python3. Potential patch:

{{{

--- cherrypy/_cpcompat.py (revision 2829) +++ cherrypy/_cpcompat.py (working copy) @@ -201,13 +201,14 @@ # Python 2. We have to do it in this order so Python 2 builds # don't try to import the 'http' module from cherrypy.lib from Cookie import SimpleCookie, CookieError - from httplib import BadStatusLine, HTTPConnection, HTTPSConnection, IncompleteRead, NotConnected from BaseHTTPServer import BaseHTTPRequestHandler except ImportError: # Python 3 from http.cookies import SimpleCookie, CookieError from http.client import BadStatusLine, HTTPConnection, HTTPSConnection, IncompleteRead, NotConnected from http.server import BaseHTTPRequestHandler +else: + from httplib import BadStatusLine, HTTPConnection, HTTPSConnection, IncompleteRead, NotConnected

try: # Python 2

}}}

Comments (1)

  1. Log in to comment