Issue 1178141: urllib.py overwrite HTTPError code with 200 (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/41818

classification

Title: urllib.py overwrite HTTPError code with 200
Type: Stage:
Components: Library (Lib) Versions: Python 2.3

process

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.

Files
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 user_id=764593 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 user_id=849994 I cannot see the point of the patch and cannot reproduce the error.
msg24925 - (view) Author: Jim Jewett (jimjjewett) Date: 2006-02-20 21:53
Logged In: YES user_id=764593 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 user_id=849994 Okay, reopening.
msg24927 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2006-02-22 20:17
Logged In: YES user_id=28665 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 overwritten. 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 problem.
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.
History
Date User Action Args
2022-04-11 14:56:10 admin set github: 41818
2008-01-20 11:43:16 georg.brandl set status: open -> closedresolution: acceptedmessages: +
2008-01-05 14:10:45 vila set nosy: + vila
2005-04-06 22:48:40 barry-scott create