New submission from Jakub Wilk <[email protected]>:
It is a surprisingly common error in 3rd party code to write something like
this:
try:
eggs()
except OSError, e:
if e.errno == 17:
ham()
This is wrong, because according to POSIX[0], “only […] symbolic names should
be used in programs, since the actual value of the error number is unspecified.”
I was wondering why Python programmers keep writing such unportable code - e.g.
I've never seen C code that would compare errno variable with a hardcoded
integer. I came into conclution that the Python interpreter itself is
(partially) to blame. Currently exception message generated from errno looks
like this:
"[Errno 2] No such file or directory: '/punt'"
It would be better if the message was:
"[ENOENT] No such file or directory: '/punt'"
or, if the above is too hard to implement, even:
"No such file or directory: '/punt'"
----------
messages: 142207
nosy: jwilk
priority: normal
severity: normal
status: open
title: EnvironmentError_str contributes to unportable code
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com