@@ -127,6 +127,7 @@ corresponding Unix manual entries for more information on calls.";
127127#define HAVE_POPEN 1
128128#define HAVE_SYSTEM 1
129129#define HAVE_WAIT 1
130+ #define HAVE_TTYNAME 1
130131#endif /* _MSC_VER */
131132#endif /* __BORLANDC__ */
132133#endif /* ! __WATCOMC__ || __QNX__ */
@@ -561,6 +562,20 @@ posix_access(self, args)
561562 return (PyInt_FromLong (res == 0 ? 1L : 0L ));
562563}
563564
565+ #ifndef F_OK
566+ #define F_OK 0
567+ #endif
568+ #ifndef R_OK
569+ #define R_OK 4
570+ #endif
571+ #ifndef W_OK
572+ #define W_OK 2
573+ #endif
574+ #ifndef X_OK
575+ #define X_OK 1
576+ #endif
577+
578+ #ifdef HAVE_TTYNAME
564579static char posix_ttyname__doc__ [] =
565580"ttyname(fd, mode) -> String\n\
566581Return the name of the terminal device connected to 'fd'." ;
@@ -582,6 +597,7 @@ posix_ttyname(self, args)
582597 return (posix_error ());
583598 return (PyString_FromString (ret ));
584599}
600+ #endif
585601
586602static char posix_chdir__doc__ [] =
587603"chdir(path) -> None\n\
@@ -2859,7 +2875,9 @@ posix_statvfs(self, args)
28592875
28602876static PyMethodDef posix_methods [] = {
28612877 {"access" , posix_access , 0 , posix_access__doc__ },
2878+ #ifdef HAVE_TTYNAME
28622879 {"ttyname" , posix_ttyname , 0 , posix_ttyname__doc__ },
2880+ #endif
28632881 {"chdir" , posix_chdir , 0 , posix_chdir__doc__ },
28642882 {"chmod" , posix_chmod , 0 , posix_chmod__doc__ },
28652883#ifdef HAVE_CHOWN
0 commit comments