summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-06 22:52:38 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-06 22:52:38 (GMT)
commit015f22a0fa6b2f818300bc35ccfd2be05b126933 (patch)
tree4da7a0b6af1915552734c277d90c947bc8a9578e
parentfcc5910090ff82b1514dc5e0746dbaaab35f8f81 (diff)
downloadcpython-015f22a0fa6b2f818300bc35ccfd2be05b126933.zip
cpython-015f22a0fa6b2f818300bc35ccfd2be05b126933.tar.gz
cpython-015f22a0fa6b2f818300bc35ccfd2be05b126933.tar.bz2
Change the access() code to return 1 if granted, 0 if not granted.
Patch (again) by Sean Reifschneider.
-rw-r--r--Modules/posixmodule.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 6cc3a2c..dd3cb72 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -522,7 +522,7 @@ posix_do_stat(self, args, statfunc)
/* POSIX methods */
static char posix_access__doc__[] =
-"access(path, mode) -> None\n\
+"access(path, mode) -> 1 if granted, 0 otherwise\n\
Test for access to a file.";
static PyObject *
@@ -530,7 +530,16 @@ posix_access(self, args)
PyObject *self;
PyObject *args;
{
- return posix_strint(args, access);
+ char *path;
+ int mode;
+ int res;
+
+ if (!PyArg_Parse(args, "(si)", &path, &mode))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS
+ res = access(path, mode);
+ Py_END_ALLOW_THREADS
+ return(PyInt_FromLong(res == 0 ? 1L : 0L));
}
static char posix_ttyname__doc__[] =
@@ -546,11 +555,9 @@ posix_ttyname(self, args)
int id;
char *ret;
-
if (!PyArg_Parse(args, "i", &id))
return NULL;
- /* XXX Use ttyname_r if it exists? */
ret = ttyname(id);
if (ret == NULL)
return(posix_error());