[CherryPy] #1076: Import error of HTTPSConnection is hidden by python3 compatibility.

7 views
Skip to first unread message

CherryPy

unread,
Jul 21, 2011, 4:57:29 PM7/21/11
to cherrypy...@googlegroups.com
#1076: Import error of HTTPSConnection is hidden by python3 compatibility.
---------------------------+------------------------------------------------
Reporter: guest | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Keywords:
---------------------------+------------------------------------------------
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

}}}

--
Ticket URL: <http://www.cherrypy.org/ticket/1076>
CherryPy <http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework
Reply all
Reply to author
Forward
0 new messages