[New-bugs-announce] [issue9792] create_connection() recasts timeout errors

Antoine Pitrou report at bugs.python.org
Tue Sep 7 21:50:14 CEST 2010


New submission from Antoine Pitrou <pitrou at free.fr>:

When you call socket.create_connection() and it fails because it hits the socket timeout, the socket.timeout error is recast as a generic socket.error, which makes analyzing the failure more difficult (also, it means the "errno" attribute is lost for other types of errors):

>>> socket.setdefaulttimeout(0.000001)
>>> s = socket.socket()
>>> s.connect(("www.yahoo.fr", 80))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.timeout: timed out
>>> socket.create_connection(("www.yahoo.fr", 80))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/antoine/py3k/__svn__/Lib/socket.py", line 319, in create_connection
    raise err
socket.error: timed out

----------
components: Library (Lib)
messages: 115798
nosy: exarkun, facundobatista, giampaolo.rodola, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: create_connection() recasts timeout errors
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9792>
_______________________________________


More information about the New-bugs-announce mailing list