[Python-Dev] Assign to errno allowed?
Guido van Rossum
guido@python.org
Wed, 25 Sep 2002 12:32:29 -0400
> > Question. You showed that errno was #defined as a call to the right
> > function. Why don't you leave *getting* errno alone?
>
> Sorry I forgot to clarify that part.
>
> Windows CE 1 and 2 have "errno", but in CE 3.0 they improved
> the OS by eliminating errno and replacing it with
> GetLastError()
>
> I suspect this was done to allow CE to be embedded on new
> processor types that would not otherwise be supported.
>
>
> > You talk of 100s of places using errno. But how many places *set*
> > errno?
>
> In the modules dir, grep shows:
>
> File cmathmodule.c:
> Py_SetErrno(0);
> File cPickle.c:
> Py_SetErrno(0);
> Py_SetErrno(0);
> Py_SetErrno(0);
> File mathmodule.c:
> Py_SetErrno(0);
> Py_SetErrno(0);
> Py_SetErrno(0);
> Py_SetErrno(0);
> Py_SetErrno(0);
>
> But alas for the GetLastError() issue, this wouldn't be so bad.
Well, *that* is easily solved in pyport.h:
#ifdef ...WINCE...
#ifndef errno
#define errno GetLastError()
#endif
#endif
Much better than changing every use of errno, isn't it? :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)