Message142207
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'" |
|
Date |
User |
Action |
Args |
2011-08-16 17:09:06 | jwilk | set | recipients:
+ jwilk |
2011-08-16 17:09:06 | jwilk | set | messageid: <1313514546.35.0.211291095895.issue12762@psf.upfronthosting.co.za> |
2011-08-16 17:09:05 | jwilk | link | issue12762 messages |
2011-08-16 17:09:05 | jwilk | create | |
|