Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d371ff1

Browse files
committed
Only do ttyname() when HAVE_TTYNAME is defined.
Also define F_OK etc. when not already defined, when doing access().
1 parent 27e0420 commit d371ff1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Modules/posixmodule.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
564579
static char posix_ttyname__doc__[] =
565580
"ttyname(fd, mode) -> String\n\
566581
Return 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

586602
static char posix_chdir__doc__[] =
587603
"chdir(path) -> None\n\
@@ -2859,7 +2875,9 @@ posix_statvfs(self, args)
28592875

28602876
static 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

Comments
 (0)