]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Correct arithmetic in access on Win32. Fixes #1513646.
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 2 Jul 2006 18:44:00 +0000 (18:44 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 2 Jul 2006 18:44:00 +0000 (18:44 +0000)
Lib/test/test_os.py
Misc/NEWS
Modules/posixmodule.c

index ffc9420ec3dfeac9a1517a1c749ad13c9873a2bc..faaadeccc2b1b8e84cc4f510271db4f6c1f16b8e 100644 (file)
@@ -11,6 +11,19 @@ from test import test_support
 warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
 warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
 
+# Tests creating TESTFN
+class FileTests(unittest.TestCase):
+    def setUp(self):
+        if os.path.exists(test_support.TESTFN):
+            os.unlink(test_support.TESTFN)
+    tearDown = setUp
+
+    def test_access(self):
+        f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+        os.close(f)
+        self.assert_(os.access(test_support.TESTFN, os.W_OK))
+
 class TemporaryFileTests(unittest.TestCase):
     def setUp(self):
         self.files = []
@@ -393,6 +406,7 @@ if sys.platform != 'win32':
 
 def test_main():
     test_support.run_unittest(
+        FileTests,
         TemporaryFileTests,
         StatAttributeTests,
         EnvironTests,
index 641b7a77d444d523fd9369449475691675769b0e..a6b4c2e0375d431f1b9dc25bf4a540eade7fc509 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,9 @@ Library
 Extension Modules
 -----------------
 
+- Bug #1513646: os.access on Windows now correctly determines write
+  access, again.
+
 - Bug #1512695: cPickle.loads could crash if it was interrupted with
   a KeyboardInterrupt.
 
index 6dcf1b00c1c29fe09e8ffd72cb1b54a766945c79..d8cf40ed7c0621160400651a0a7ebd26b240459b 100644 (file)
@@ -1402,7 +1402,7 @@ finish:
                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));
+       return PyBool_FromLong(!(mode & 2) || !(attr & FILE_ATTRIBUTE_READONLY));
 #else
        int res;
        if (!PyArg_ParseTuple(args, "eti:access",