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.

Author ezio.melotti
Recipients amaury.forgeotdarc, ezio.melotti, georg.brandl, orsenthil, r.david.murray
Date 2010-02-27.09:24:59
SpamBayes Score 1.7877634e-06
Marked as misclassified No
Message-id <1267262702.45.0.403524213706.issue6471@psf.upfronthosting.co.za>
In-reply-to
Content
Can this be fixed without breaking compatibility?
It also affects Python2.7 and maybe also Python 3.x (there the error is different and might be intentional).

Copy/pastable snippet to reproduce the error on 2.x:
from urllib import urlopen
try:
    urlopen('http://www.pythonfoobarbaz.org')
except Exception, err:
    print 'err:', err
    print 'repr(err):', repr(err)
    print 'err.errno:', err.errno
    print 'err.strerror:', err.strerror
    print 'err.strerror.errno:', err.strerror.errno
    print 'err.strerror.strerror:', err.strerror.strerror

Result on 2.7:
err: [Errno socket error] [Errno -2] Name or service not known
repr(err): IOError('socket error', gaierror(-2, 'Name or service not known'))
err.errno: socket error
err.strerror: [Errno -2] Name or service not known
err.strerror.errno: -2
err.strerror.strerror: Name or service not known


Copy/pastable snippet to reproduce the error on 3.x:
from urllib.request import urlopen
try:
    urlopen('http://www.pythonfoobarbaz.org')
except Exception as exc:
    err = exc
    print('err:', err)
    print('repr(err):', repr(err))
    print('err.errno:', err.errno)
    print('err.strerror:', err.strerror)
    print('err.reason:', err.reason)
    print('err.reason.errno:', err.reason.errno)
    print('err.reason.strerror:', err.reason.strerror)

Result on 3.2:
err: <urlopen error [Errno -2] Name or service not known>
repr(err): URLError(gaierror(-2, 'Name or service not known'),)
err.errno: None
err.strerror: None
err.reason: [Errno -2] Name or service not known
err.reason.errno: -2
err.reason.strerror: Name or service not known
History
Date User Action Args
2010-02-27 09:25:02ezio.melottisetrecipients: + ezio.melotti, georg.brandl, amaury.forgeotdarc, orsenthil, r.david.murray
2010-02-27 09:25:02ezio.melottisetmessageid: <1267262702.45.0.403524213706.issue6471@psf.upfronthosting.co.za>
2010-02-27 09:25:00ezio.melottilinkissue6471 messages
2010-02-27 09:24:59ezio.melotticreate