This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: overwrite HTTPError code with 200
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: barry-scott, georg.brandl, jimjjewett, vila
Priority: normal Keywords:

Created on 2005-04-06 22:48 by barry-scott, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
urllib.patch barry-scott, 2005-04-10 21:15 urllib.patch
Messages (7)
msg24922 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2005-04-06 22:48
I found this bug while trying to understand why a 404
Not Found error was reported as a 200 Not Found.

Turns out the HTTPError's self.code is overwritten with
200 after
the 404 was correctly assigned.

The attached patch fixes the problem.
msg24923 - (view) Author: Jim Jewett (jimjjewett) Date: 2005-04-08 16:18
Logged In: YES 

Please reattach (SF didn't catch the file)
msg24924 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-20 21:30
Logged In: YES 

I cannot see the point of the patch and cannot reproduce the
msg24925 - (view) Author: Jim Jewett (jimjjewett) Date: 2006-02-20 21:53
Logged In: YES 

Barry -- Are you sure that the original status code wasn't 
204?  If so, then this patch makes more sense.

Georg -- any unrecognized response status NXX should be 
treated as N00.  Since 204 (and 298, for that matter) aren't 
recognized by the urllib opener, they should be treated as 
200, which the patch does.  

Whether the patch makes it harder to treat 204 separately 
when it is recognized is another issue.
msg24926 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-22 11:32
Logged In: YES 

Okay, reopening.
msg24927 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2006-02-22 20:17
Logged In: YES 

There are two problems.
1) 200-299 are all good, not just 200
2) Setting the code in addinfourl needs to use the
   2xx code that came from the server

I have a complex http app that broken without this fix.
I'm doing partial transfers that return 206 that was being

This is clearly a bug. The only issue is does the patch fix
the bug and not cause other problems? In nearly a year of
running with this patch on 700 systems I've not seen a
msg61273 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-01-20 11:43
The bug (interpreting non-200 2xx codes as error) has already been
fixed. I've finished and committed the other part (adding getcode() to
addinfourl) in r60133.
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41818
2008-01-20 11:43:16georg.brandlsetstatus: open -> closed
resolution: accepted
messages: + msg61273
2008-01-05 14:10:45vilasetnosy: + vila
2005-04-06 22:48:40barry-scottcreate