[Python-checkins] r59312 - in python/trunk: Misc/NEWS Modules/posixmodule.c

martin.v.loewis python-checkins at python.org
Tue Dec 4 00:09:04 CET 2007


Author: martin.v.loewis
Date: Tue Dec  4 00:09:04 2007
New Revision: 59312

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/posixmodule.c
Log:
Forward-port r59310:
os.access now returns True on Windows for any existing directory.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Dec  4 00:09:04 2007
@@ -310,6 +310,8 @@
 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

Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c	(original)
+++ python/trunk/Modules/posixmodule.c	Tue Dec  4 00:09:04 2007
@@ -1540,8 +1540,11 @@
 		/* 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", 


More information about the Python-checkins mailing list