diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-03-09 12:07:51 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-03-09 12:07:51 (GMT) |
commit | 3484a18af1ad1998bc0677befddf5d0a87f6a682 (patch) | |
tree | c7c2dac5a263c96644a66d17371e9feff0b1891f /Python/bltinmodule.c | |
parent | c8bb9eba31bb9352b1fdf19da490b3238fe8cb3e (diff) | |
download | cpython-3484a18af1ad1998bc0677befddf5d0a87f6a682.zip cpython-3484a18af1ad1998bc0677befddf5d0a87f6a682.tar.gz cpython-3484a18af1ad1998bc0677befddf5d0a87f6a682.tar.bz2 |
Patch #494045: patches errno and stat to cope on plan9.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 41e906a..1561a22 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -536,9 +536,6 @@ builtin_execfile(PyObject *self, PyObject *args) 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 @@ builtin_execfile(PyObject *self, PyObject *args) 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 |