New submission from Longpoke <longp...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue8573>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to