Problem with infinite recursion in urllib2

Bent Solheim encrypted100 at hotmail.com
Wed Jan 16 12:52:21 EST 2002


I noticed that this bug is fixed in Python 2.2. Apparently the fix was
to replace line 457 (Python 2.0) with

raise HTTPError(req.get_full_url(), code, self.inf_msg + msg, headers,
fp)

urllib2 will still throw an exception, but this time in a more
controlled manner...


Still looking for anybody with a suggestion to how to solve the last
problem (passwordmanager) described in the root posting.


\Bent



encrypted100 at hotmail.com (Bent Solheim) wrote in message news:<3088ee04.0201150927.2ac4a47c at posting.google.com>...
> I’m trying to open http://www.fwi.co.uk with urllib2, but get
> the following error:
> Exception exceptions.AttributeError: "'HTTPError' instance has no
> attribute 'fp' " in <method HTTPError.__del__ of HTTPError instance at
> 0x811f7ec> ignored Traceback (most recent call last):
> <cut traceback>
> 
> Previously, in urllib, infinite recursion caused the Python
> interpreter to hang, but in urllib2 this problem is supposed to be
> solved. But is this the expected behaviour? In my opinion, this is
> wrong. Shouldn’t urllib2 try to resolve the recursion problem
> instead of throwing an exception? I.e when encountering a circular
> redirect, stop at the url redirecting to the first...
> 
> Also in urllib2 on line 613, why use get_host instead of get_full_url.
> The way I see it, using get_full_url will result in a more propper
> behaviour. I.e. any suburi of the one stored in the passwordmanager
> should return a password.
> 
> Best regards
> curious bent



More information about the Python-list mailing list