This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jwilk
Recipients jwilk
Date 2011-08-16.17:09:05
SpamBayes Score 2.7594016e-09
Marked as misclassified No
Message-id <1313514546.35.0.211291095895.issue12762@psf.upfronthosting.co.za>
In-reply-to
Content
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'"
History
Date User Action Args
2011-08-16 17:09:06jwilksetrecipients: + jwilk
2011-08-16 17:09:06jwilksetmessageid: <1313514546.35.0.211291095895.issue12762@psf.upfronthosting.co.za>
2011-08-16 17:09:05jwilklinkissue12762 messages
2011-08-16 17:09:05jwilkcreate