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.

classification
Title: fix urllib to raise IOError correctly
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: dugsong, georg.brandl
Priority: normal Keywords: patch

Created on 2006-12-20 06:42 by dugsong, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib.diff dugsong, 2006-12-20 06:42 urllib raised IOError fix
Messages (2)
msg51585 - (view) Author: Dug Song (dugsong) Date: 2006-12-20 06:42
urllib.URLopener's http_error_default() is supposed to raise IOError on failure, but does this with an invalid number of arguments, resulting in a TypeError:

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib.py", line 357, in http_error_default
    raise IOError('http error', errcode, errmsg, headers)
TypeError: EnvironmentError expected at most 3 arguments, got 4

removing the extraneous "headers" argument, the raised exception works as intended:

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib.py", line 357, in http_error_default
    raise IOError, ('http error', errcode, errmsg)
IOError: [Errno http error] 401: 'Unauthorized'
msg51586 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-12-20 08:16
Thanks for reporting, this was already fixed in response to bug #1566800.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44365
2006-12-20 06:42:38dugsongcreate