Urllib2 upgrade is breaking urlopen()

Jay Davis dj00302003 at yahoo.com
Fri Jan 23 03:18:51 CET 2004


We have a lot of simple code using 'urllib', that basically
just goes out and opens and read()'s some http url.  Very basic,
ten line scripts, and they work fine with urllib.

We want to use urllib2 for everything, though, but when we
do we get: 

page=urllib2.urlopen("http://www.something.com/whatever.php")
...
  File "/usr/lib/python2.3/urllib2.py", line 306, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.3/urllib2.py", line 463, in http_error_302
    self.inf_msg + msg, headers, fp)
urllib2.HTTPError: HTTP Error 302: The HTTP server returned a redirect
error that would lead to an infinite loop.
The last 30x error message was:
Found


These redirect errors just don't happen with urrlib.urlopen(), and I
can
only find a few posts on deja that even mention this problem.  Is
there a known workaround?

Thanks,

J.D.



More information about the Python-list mailing list