Ezio Melotti <ezio.melo...@gmail.com> added the comment:

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

----------
nosy: +orsenthil
stage:  -> needs patch
versions: +Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6471>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to