Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 22205:f4487350c537 legacy-trunk
Patch #494045: patches errno and stat to cope on plan9.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sat, 09 Mar 2002 12:07:51 +0000 |
| parents | 67a5e25dc88b |
| children | aa8d59823add |
line wrap: on
line diff
--- a/Python/bltinmodule.c Sat Mar 09 12:02:59 2002 +0000 +++ b/Python/bltinmodule.c Sat Mar 09 12:07:51 2002 +0000 @@ -536,9 +536,6 @@ FILE* fp = NULL; PyCompilerFlags cf; int exists; -#ifndef RISCOS - struct stat s; -#endif if (!PyArg_ParseTuple(args, "s|O!O!:execfile", &filename, @@ -560,25 +557,40 @@ exists = 0; /* Test for existence or directory. */ -#ifndef RISCOS - if (!stat(filename, &s)) { - if (S_ISDIR(s.st_mode)) -#if defined(PYOS_OS2) && defined(PYCC_VACPP) - errno = EOS2ERR; -#else - errno = EISDIR; -#endif - else - exists = 1; +#if defined(PLAN9) + { + Dir *d; + + if ((d = dirstat(filename))!=nil) { + if(d->mode & DMDIR) + werrstr("is a directory"); + else + exists = 1; + free(d); + } } -#else +#elif defined(RISCOS) if (object_exists(filename)) { if (isdir(filename)) errno = EISDIR; else exists = 1; } -#endif /* RISCOS */ +#else /* standard Posix */ + { + struct stat s; + if (stat(filename, &s) == 0) { + if (S_ISDIR(s.st_mode)) +# if defined(PY_OS2) && defined(PYCC_VACPP) + errno = EOS2ERR; +# else + errno = EISDIR; +# endif + else + exists = 1; + } + } +#endif if (exists) { Py_BEGIN_ALLOW_THREADS
