From c8dbc92395765e476341ed65f6e88e74fd7db01b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 3 Dec 2007 22:39:10 +0000 Subject: [PATCH] os.access now returns True on Windows for any existing directory. --- Misc/NEWS | 2 ++ Modules/posixmodule.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 7172f83a34..735b073bd1 100644 --- 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. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 215930f2a2..aaaa838c27 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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", -- 2.50.0