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.

Title: getaddrinfo raises near-useless exception
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: balazs, ned.deily, neologix, nikratio
Priority: normal Keywords:

Created on 2013-09-19 03:38 by nikratio, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg198039 - (view) Author: Nikolaus Rath (nikratio) * Date: 2013-09-19 03:38
I received a bugreport for a Python application that contains the following stacktrace:

>   File "/usr/lib/python3.3/http/", line 1057, in endheaders
>     self._send_output(message_body)
>   File "/usr/lib/python3.3/http/", line 902, in _send_output
>     self.send(msg)
>   File "/usr/lib/python3.3/http/", line 840, in send
>     self.connect()
>   File "/usr/lib/python3.3/http/", line 1194, in connect
>     self.timeout, self.source_address)
>   File "/usr/lib/python3.3/", line 417, in create_connection
>     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
> OSError: [Errno 0] Error

My guess is that something went wrong with the name resolution, but it seems near impossible to handle this in the application because apparently the exception contains no machine usable useful informaton at all. 

It would be nice if whatever information Python used to determine that the getaddrinfo call failed could be included in the exception, so that it can be properly caught and handled.
msg198040 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-09-19 04:00
This looks like a platform bug. What platform was this running on?  A web search turns up other reports of the system getaddrinfo() returning errno = 0 due to a glibc bug, for example,
msg198133 - (view) Author: Balazs (balazs) Date: 2013-09-20 08:31
Hi, this is the platform:

Linux cloudbackupbr 3.8.0-30-generic #44-Ubuntu SMP Thu Aug 22 20:52:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x6db033ec6858b391e114e252b3354ddbf5a9f7be, stripped

msg198155 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2013-09-20 17:43
Well, as Ned explained, that's a libc bug.
If getaddrinfo() fails with EAI_SYSTEM, errno should be set.

There's nothing more Python can do.
If the error is reproducible, you can run the failing code with strace, to see what's going on (and check if there's a more recent glib version which could fix this bug).
Date User Action Args
2022-04-11 14:57:51adminsetgithub: 63244
2013-09-20 17:43:43neologixsetstatus: open -> closed
resolution: not a bug
messages: + msg198155

stage: resolved
2013-09-20 08:31:26balazssetmessages: + msg198133
2013-09-19 07:54:55balazssetnosy: + balazs
2013-09-19 06:25:37pitrousetnosy: + neologix
2013-09-19 04:00:55ned.deilysetnosy: + ned.deily
messages: + msg198040
2013-09-19 03:38:52nikratiocreate