[issue8573] Buggy _strerror in asyncore

Longpoke report at bugs.python.org
Thu Apr 29 22:30:29 CEST 2010


New submission from Longpoke <longpoke at gmail.com>:

This function in asyncore is buggy:

def _strerror(err):
    res = os.strerror(err)
    if res == 'Unknown error':
        res = errorcode[err]
    return res

- os.strerror may throw ValueError depending on the os, or return a string saying something like: "Unknown error 1234".
- os.strerror never returns "Unknown error" for me, so "Unknown error <err>" is always returned for me (Linux 2.6.32)
- if os.strerrror failed, it's likely that it wont be in errno.errcode either

Maybe it should be written like this:
def _strerror(err):
    try:
        return strerror(err)
    except ValueError:
        return "Unknown error {0}".format(err)

----------
components: Library (Lib)
messages: 104583
nosy: q94IjzUfnNoyv4c75mMw
priority: normal
severity: normal
status: open
title: Buggy _strerror in asyncore
type: crash
versions: Python 2.6

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


More information about the Python-bugs-list mailing list