pumazi/wsgi_intercept2 — Issue #10: 10 - urllib2 intercept fails for Python 2.4+ when SSL is not available 
Author: pumazi
Created: 2011-12-22 19:25:21+00:00
State: open

The module `wsgi_intercept.urllib2_intercept.wsgi_urllib2` cannot be
imported on Python >= 2.4 when SSL is not available because it
unconditionally tries to import `urllib2.HTTPSHandler`. This module
has similar logic about whether the class is going to exist or not.

The fix is simple::

from wsgi_intercept import WSGI_HTTPConnection

import urllib2, httplib
-from urllib2 import HTTPHandler
+from urllib2 import HTTPHandler, HTTPSHandler
from httplib import HTTP

#
@@ -34,7 +34,6 @@
return self.do_open(WSGI_HTTPConnection, req)

if hasattr(httplib, 'HTTPS'):
- from urllib2 import HTTPSHandler
# urllib2 does this check as well, I assume it's to see if
# python was compiled with SSL support
class WSGI_HTTPSHandler(HTTPSHandler):

Cheers,
Ashley

Original link: http://code.google.com/p/wsgi-intercept/issues/detail?id=10