Patch #494045: patches errno and stat to cope on plan9.

This commit is contained in:
Martin v. Löwis 2002-03-09 12:07:51 +00:00
parent c8bb9eba31
commit 3484a18af1
2 changed files with 36 additions and 16 deletions

View file

@ -536,9 +536,6 @@ builtin_execfile(PyObject *self, PyObject *args)
FILE* fp = NULL; FILE* fp = NULL;
PyCompilerFlags cf; PyCompilerFlags cf;
int exists; int exists;
#ifndef RISCOS
struct stat s;
#endif
if (!PyArg_ParseTuple(args, "s|O!O!:execfile", if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
&filename, &filename,
@ -560,10 +557,31 @@ builtin_execfile(PyObject *self, PyObject *args)
exists = 0; exists = 0;
/* Test for existence or directory. */ /* Test for existence or directory. */
#ifndef RISCOS #if defined(PLAN9)
if (!stat(filename, &s)) { {
Dir *d;
if ((d = dirstat(filename))!=nil) {
if(d->mode & DMDIR)
werrstr("is a directory");
else
exists = 1;
free(d);
}
}
#elif defined(RISCOS)
if (object_exists(filename)) {
if (isdir(filename))
errno = EISDIR;
else
exists = 1;
}
#else /* standard Posix */
{
struct stat s;
if (stat(filename, &s) == 0) {
if (S_ISDIR(s.st_mode)) if (S_ISDIR(s.st_mode))
#if defined(PYOS_OS2) && defined(PYCC_VACPP) # if defined(PY_OS2) && defined(PYCC_VACPP)
errno = EOS2ERR; errno = EOS2ERR;
# else # else
errno = EISDIR; errno = EISDIR;
@ -571,14 +589,8 @@ builtin_execfile(PyObject *self, PyObject *args)
else else
exists = 1; exists = 1;
} }
#else
if (object_exists(filename)) {
if (isdir(filename))
errno = EISDIR;
else
exists = 1;
} }
#endif /* RISCOS */ #endif
if (exists) { if (exists) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS

View file

@ -264,6 +264,9 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
PyObject *v; PyObject *v;
char *s; char *s;
int i = errno; int i = errno;
#ifdef PLAN9
char errbuf[ERRMAX];
#endif
#ifdef MS_WIN32 #ifdef MS_WIN32
char *s_buf = NULL; char *s_buf = NULL;
#endif #endif
@ -271,6 +274,10 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
if (i == EINTR && PyErr_CheckSignals()) if (i == EINTR && PyErr_CheckSignals())
return NULL; return NULL;
#endif #endif
#ifdef PLAN9
rerrstr(errbuf, sizeof errbuf);
s = errbuf;
#else
if (i == 0) if (i == 0)
s = "Error"; /* Sometimes errno didn't get set */ s = "Error"; /* Sometimes errno didn't get set */
else else
@ -305,7 +312,8 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
s[--len] = '\0'; s[--len] = '\0';
} }
} }
#endif #endif /* Unix/Windows */
#endif /* PLAN 9*/
if (filename != NULL) if (filename != NULL)
v = Py_BuildValue("(iss)", i, s, filename); v = Py_BuildValue("(iss)", i, s, filename);
else else