kevinsl / wsgi-intercept

Automatically exported from code.google.com/p/wsgi-intercept
Other
0 stars 0 forks source link

urllib2 intercept fails for Python 2.4+ when SSL is not available #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 issue reported on code.google.com by ashleywa...@gmail.com on 23 Jan 2008 at 9:13

GoogleCodeExporter commented 8 years ago
huh, I thought I fixed that.  It might be buried in a branch somewhere.  But 
thanks
for the report, this will help me thoroughly check that the change gets into 
next
bugfix release (will be 0.3.x).

Original comment by kumar.mcmillan on 23 Jan 2008 at 3:26

GoogleCodeExporter commented 8 years ago
I'm still seeing this behavior with 0.4 on Python 2.6.

Original comment by benji.y...@gmail.com on 24 May 2010 at 9:09

GoogleCodeExporter commented 8 years ago
This was fixed in r52 and in v0.5.0.

Original comment by p4pe...@gmail.com on 24 May 2011 at 3:45

GoogleCodeExporter commented 8 years ago
Aha, so it was.

Original comment by kumar.mcmillan on 24 May 2011 at 3:49