[issue2413] os.strerror does not check for out of range argument
report at bugs.python.org
Wed Mar 19 23:02:58 CET 2008
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
And on some system "Unknown error: nnn" is returned with no error indication.
Your concern that the patch is invalid on some unidentified system.
can easily be addressed by checking for NULL return *in addition* to
the errno check.
The real question is whether it is desirable to raise ValueError from
error code is out of bound. I would say the existing code intends to
do exactly that,
but th error check is incorrect on at least one popular platform. I
believe it is better
to raise an error because as a user, seeing "unknown error has
is one of the worst experiences.
On the other hand, if the consensus is that strerror() should always
(short of out of
memory condition) return a string, then (assuming null return is a
possibility) the code
needs to be changed to return "Unknown error: nnn" instead of raising an error.
Tracker <report at bugs.python.org>
More information about the Python-bugs-list