File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -536,9 +536,6 @@ builtin_execfile(PyObject *self, PyObject *args)
536536 FILE * fp = NULL ;
537537 PyCompilerFlags cf ;
538538 int exists ;
539- #ifndef RISCOS
540- struct stat s ;
541- #endif
542539
543540 if (!PyArg_ParseTuple (args , "s|O!O!:execfile" ,
544541 & filename ,
@@ -560,25 +557,40 @@ builtin_execfile(PyObject *self, PyObject *args)
560557
561558 exists = 0 ;
562559 /* Test for existence or directory. */
563- #ifndef RISCOS
564- if (!stat (filename , & s )) {
565- if (S_ISDIR (s .st_mode ))
566- #if defined(PYOS_OS2 ) && defined(PYCC_VACPP )
567- errno = EOS2ERR ;
568- #else
569- errno = EISDIR ;
570- #endif
571- else
572- exists = 1 ;
560+ #if defined(PLAN9 )
561+ {
562+ Dir * d ;
563+
564+ if ((d = dirstat (filename ))!= nil ) {
565+ if (d -> mode & DMDIR )
566+ werrstr ("is a directory" );
567+ else
568+ exists = 1 ;
569+ free (d );
570+ }
573571 }
574- #else
572+ #elif defined( RISCOS )
575573 if (object_exists (filename )) {
576574 if (isdir (filename ))
577575 errno = EISDIR ;
578576 else
579577 exists = 1 ;
580578 }
581- #endif /* RISCOS */
579+ #else /* standard Posix */
580+ {
581+ struct stat s ;
582+ if (stat (filename , & s ) == 0 ) {
583+ if (S_ISDIR (s .st_mode ))
584+ # if defined(PY_OS2 ) && defined(PYCC_VACPP )
585+ errno = EOS2ERR ;
586+ # else
587+ errno = EISDIR ;
588+ # endif
589+ else
590+ exists = 1 ;
591+ }
592+ }
593+ #endif
582594
583595 if (exists ) {
584596 Py_BEGIN_ALLOW_THREADS
Original file line number Diff line number Diff line change @@ -264,13 +264,20 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
264264 PyObject * v ;
265265 char * s ;
266266 int i = errno ;
267+ #ifdef PLAN9
268+ char errbuf [ERRMAX ];
269+ #endif
267270#ifdef MS_WIN32
268271 char * s_buf = NULL ;
269272#endif
270273#ifdef EINTR
271274 if (i == EINTR && PyErr_CheckSignals ())
272275 return NULL ;
273276#endif
277+ #ifdef PLAN9
278+ rerrstr (errbuf , sizeof errbuf );
279+ s = errbuf ;
280+ #else
274281 if (i == 0 )
275282 s = "Error" ; /* Sometimes errno didn't get set */
276283 else
@@ -305,7 +312,8 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
305312 s [-- len ] = '\0' ;
306313 }
307314 }
308- #endif
315+ #endif /* Unix/Windows */
316+ #endif /* PLAN 9*/
309317 if (filename != NULL )
310318 v = Py_BuildValue ("(iss)" , i , s , filename );
311319 else
You can’t perform that action at this time.
0 commit comments