]> granicus.if.org Git - python/commitdiff
os.access now returns True on Windows for any existing directory.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 3 Dec 2007 22:39:10 +0000 (22:39 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 3 Dec 2007 22:39:10 +0000 (22:39 +0000)
Misc/NEWS
Modules/posixmodule.c

index 7172f83a34d61a21142a32022d17f50b5e03fd9a..735b073bd1e0316c9946c240119d71c6ae42c333 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -46,6 +46,8 @@ Core and builtins
 Library
 -------
 
+- os.access now returns True on Windows for any existing directory.
+
 - Issue #1531: tarfile.py: Read fileobj from the current offset, do not
   seek to the start.
 
index 215930f2a286615c61dc15b3cf8d682131185c62..aaaa838c275670cfa11817c0f5c67697c4461fc9 100644 (file)
@@ -1535,8 +1535,11 @@ finish:
                /* File does not exist, or cannot read attributes */
                return PyBool_FromLong(0);
        /* Access is possible if either write access wasn't requested, or
-          the file isn't read-only. */
-       return PyBool_FromLong(!(mode & 2) || !(attr & FILE_ATTRIBUTE_READONLY));
+          the file isn't read-only, or if it's a directory, as there are
+          no read-only directories on Windows. */
+       return PyBool_FromLong(!(mode & 2) 
+                              || !(attr & FILE_ATTRIBUTE_READONLY)
+                              || (attr & FILE_ATTRIBUTE_DIRECTORY));
 #else
        int res;
        if (!PyArg_ParseTuple(args, "eti:access",