Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6139

Re: os.access giving incorrect results on Windows

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'permissions': 0.04; 'suggestions.': 0.07; 'python': 0.08; 'assert': 0.09; 'executed': 0.09; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'api': 0.11; 'essentially': 0.11; 'def': 0.12; 'error:': 0.12; 'bangalore': 0.14; 'wrote:': 0.14; 'defined': 0.14; '[errno': 0.16; 'deprecate': 0.16; 'oserror:': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'tests)': 0.16; 'thread.': 0.16; 'permission': 0.16; 'traceback': 0.16; '(most': 0.16; 'cc:addr:python-list': 0.17; 'skip:= 70': 0.17; 'discussion': 0.19; 'suggest': 0.19; 'script.': 0.19; 'subject:Windows': 0.20; 'header:In-Reply-To:1': 0.21; 'wrote': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'last):': 0.23; 'code': 0.24; "doesn't": 0.25; 'there.': 0.25; 'function': 0.25; 'user.': 0.26; 'windows': 0.26; '(in': 0.26; 'script': 0.27; 'tried': 0.27; 'example': 0.27; 'thanks': 0.28; '(not': 0.28; 'problem': 0.28; 'skip:- 70': 0.29; 'class': 0.29; 'skip:( 20': 0.30; "won't": 0.30; 'cc:addr:python.org': 0.30; 'fails,': 0.30; 'ran': 0.30; 'standalone': 0.30; 'tjg': 0.30; 'looks': 0.31; 'it.': 0.31; "can't": 0.32; "skip:' 10": 0.32; 'patch': 0.32; 'does': 0.33; 'post': 0.33; 'error': 0.33; '...': 0.34; "i'll": 0.34; 'file': 0.34; 'summary': 0.34; 'fail': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'round': 0.35; 'else': 0.35; 'using': 0.35; 'test': 0.35; 'open': 0.36; 'issue': 0.37; 'change': 0.37; 'checks': 0.37; 'case': 0.37; 'but': 0.38; 'ok,': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.38; 'should': 0.39; 'under': 0.40; 'hope': 0.60; 'your': 0.60; 'providing': 0.61; 'forward': 0.62; 'back': 0.63; 'straight': 0.63; 'reply': 0.63; 'from:addr:mail': 0.65; 'making': 0.67; 'denied:': 0.84; 'discourage': 0.84; 'python-dev': 0.84; 'tricky': 0.84; 'here...': 0.91; 'to:none': 0.93
Date Tue, 24 May 2011 15:40:53 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
MIME-Version 1.0
CC python-list@python.org
Subject Re: os.access giving incorrect results on Windows
References <21581D39FA3BDF40904D75AF9653CE26065680B9@blrex.prog.altair.com>
In-Reply-To <21581D39FA3BDF40904D75AF9653CE26065680B9@blrex.prog.altair.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2015.1306248058.9059.python-list@python.org> (permalink)
Lines 68
NNTP-Posting-Host 82.94.164.166
X-Trace 1306248058 news.xs4all.nl 49179 [::ffff:82.94.164.166]:46903
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6139

Show key headers only | View raw


On 20/05/2011 12:26, Ayaskanta Swain wrote:
 > Thanks for the reply and suggestions. I followed the patch provided by
 > you in issue 2528, but the code looks very tricky to me.

OK, first a summary of the discussion on the python-dev thread.
Essentially it was felt that os.access was sufficiently shaky
and unuseful on Windows that it was better to deprecate it and
to discourage its use. So I'll be making that change when I
can get round to it.

As to your particular problem here...

Does my_dir already exist? If it does then os.open won't be able
to create it. If it doesn't then I can't see any reason why the
code should fail there. I just ran it myself and it fails, as
expected on an unpatched Python, on the assert on line 17 where
the check is made for the result of os.access for W_OK.

I don't have the time right now but if no-one else gets there
first I hope to be able to post back with a standalone example
of the AccessCheck API

TJG

Anyways I wrote
 > my Test.py script & tried only the def test_access_w(self): test case
 > which is defined under class FileTests(unittest.TestCase) by providing
 > my own directory path to check the write permissions on it.
 >
 > I executed my But it failed with the following errors –
 >
 > *> python Test.py C:\temp\my_dir*
 >
 > test_access_w (__main__.FileTests) ... ERROR
 >
 > ======================================================================
 >
 > ERROR: test_access_w (__main__.FileTests)
 >
 > ----------------------------------------------------------------------
 >
 > Traceback (most recent call last):
 >
 > File "Test.py", line 14, in test_access_w
 >
 > f = os.open(dirpath, os.O_CREAT)
 >
 > OSError: [Errno 13] Permission denied: 'C:\\temp\\my_dir'
 >
 > ----------------------------------------------------------------------
 >
 > Ran 1 test in 0.000s
 >
 > FAILED (errors=1)
 >
 > Basically the os.open() function is failing to open a directory (In this
 > case my_dir). The directory has write permissions for the user. Attached
 > herewith is my Test script. Can you please suggest some simple python
 > code which checks the write permissions of a directory in a straight
 > forward way (Not by using unit tests)
 >
 > Thanks
 >
 > Ayaskant-
 >
 > Bangalore
 >

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: os.access giving incorrect results on Windows Tim Golden <mail@timgolden.me.uk> - 2011-05-24 15:40 +0100

csiph-web