"Message file not found"

Stefan Schwarzer s.schwarzer at ndh.net
Sun Dec 26 12:47:48 EST 1999


Hi Siggy,

thank you for your reply.

Siggy Brentrup schrieb:
> > Obviously, the (more specific) error messages in OS/2 are not there,
> > but so far I couldn't figure out how to "get them".
> 
> I'm not sure what you are looking for, obviously on OS/2 the C library
> sets errno=10 if a file doesn't exist

I would be glad, if only this would have been my mistake ;-)

> while all Unix variants I
> know of use errno=2 for this purpose.
> 
> For portability use the errno module:
> 
> Python 1.5.2+ (#4, Nov 18 1999, 01:39:08)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2 release)] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> IDLE 0.5 -- press F1 for help
> >>> import errno
> >>> try:
>         open('spam','r')
> except IOError, x:
>         if x.errno == errno.ENOENT:
>                 print 'Oops'
>         else: raise

I tried that:

Python 1.5.2 (#0, Jun 27 1999, 11:23:01) [VisualAge C/C++] on os2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import errno
>>> try:
...     open('spam','r')
... except IOError, x:
...     if x.errno == errno.ENOENT:
...             print 'Oops'
...     else: raise
...
Traceback (innermost last):
  File "<stdin>", line 2, in ?
IOError: [Errno 10] Message file not found.: 'spam'

> btw: To get the symbol for an error number use:
> 
> >>> errno.errorcode[2]
> 'ENOENT'

My errno.errorcode is

>>> errno.errorcode
{13: 'ENOMEM', 25: 'EMFILE', 24: 'EACCES', 23: 'ENOENT', 53: 'E2BIG', 52: 'EILSE
Q', 16: 'EEXIST', 45: 'ENOSPC', 44: 'EXDEV', 43: 'EBADF', 38: 'EAGAIN', 37: 'ENO
EXEC', 36: 'EINVAL', 35: 'EINTR', 34: 'ECHILD', 1: 'EDOM', 2: 'ERANGE'}

10 isn't even in the list (and ENOENT corresponds to 23). So I still
think, here Python can't find the file with which the error codes are
mapped to the full messages. Unfortunately, error 10 is issued
"before" the "real" error, so it seems I have not even a workaround
to determine the origin of a I/O failure?

Stefan



More information about the Python-list mailing list