]> granicus.if.org Git - python/commitdiff
Forward-port r59310:
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 3 Dec 2007 23:09:04 +0000 (23:09 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 3 Dec 2007 23:09:04 +0000 (23:09 +0000)
os.access now returns True on Windows for any existing directory.

Misc/NEWS
Modules/posixmodule.c

index 4c3369c7e633e3e5f35603f0bc3050635c5aaccc..9cdcbc25c2b3b49d2f71e9cef87af825da6613f8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -310,6 +310,8 @@ Core and builtins
 Library
 -------
 
+- os.access now returns True on Windows for any existing directory.
+
 - Issue #1727780: Support loading pickles of random.Random objects created
   on 32-bit systems on 64-bit systems, and vice versa. As a consequence
   of the change, Random pickles created by Python 2.6 cannot be loaded
index ff79a0e8faa70a99252f557b5bdba4c5c7f4228e..df1586068e0cf26f96463b9e3867d272a5b7b3f3 100644 (file)
@@ -1540,8 +1540,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",