diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-08-11 23:18:55 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-08-11 23:18:55 (GMT) |
commit | d7b568ac4d238281d6ac55b6d7b820c64250a09d (patch) | |
tree | b4841a3c162b3ae73fc52854e32590f5b2063294 /Mac/Modules | |
parent | b5982221bb5a45de90f58b21e121dd8677d6e25a (diff) | |
download | cpython-d7b568ac4d238281d6ac55b6d7b820c64250a09d.zip cpython-d7b568ac4d238281d6ac55b6d7b820c64250a09d.tar.gz cpython-d7b568ac4d238281d6ac55b6d7b820c64250a09d.tar.bz2 |
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Diffstat (limited to 'Mac/Modules')
-rw-r--r-- | Mac/Modules/macmodule.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Mac/Modules/macmodule.c b/Mac/Modules/macmodule.c index 7735ab3..766722f 100644 --- a/Mac/Modules/macmodule.c +++ b/Mac/Modules/macmodule.c @@ -311,6 +311,24 @@ mac_listdir(self, args) struct dirent *ep; if (!PyArg_ParseTuple(args, "s", &name)) return NULL; +#ifdef USE_GUSI + /* Work around a bug in GUSI: if you opendir() a file it will + ** actually opendir() the parent directory. + */ + { + struct stat stb; + int res; + + res = stat(name, &stb); + if ( res < 0 ) + return mac_error(); + if (!S_ISDIR(stb.st_mode) ) { + errno = ENOTDIR; + return mac_error(); + } + } +#endif + Py_BEGIN_ALLOW_THREADS if ((dirp = opendir(name)) == NULL) { Py_BLOCK_THREADS |