This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ngie
Recipients ngie
Date 2010-07-20.02:02:33
SpamBayes Score 0.06991226
Marked as misclassified No
Message-id <1279591357.64.0.139129514793.issue9311@psf.upfronthosting.co.za>
In-reply-to
Content
As seen in the nose bug [1], I stumbled upon an OS quirk with FreeBSD, where apparently (as superuser) due to the wording of the POSIX spec for access(2), it's considered free game to return 0 for the system call (True) for os.[RWX]_OK.

Only python was affected by this on the system I was using (both perl and sh did the right thing in detecting the executable bit(s) on the file).

An example should be provided to do the right thing with the stat module, and developers should be warned against using os.access because (as the patch and test log demonstrate), stat(2) does the right thing when access(2) does not as superuser...

Here's an example of the code I used to detect the executable bit:

import os
import stat

s = os.stat(afile)

executable = (s.st_mode & stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) == 0

[1] http://code.google.com/p/python-nose/issues/detail?id=351
[2] http://www.opengroup.org/onlinepubs/000095399/functions/access.html
History
Date User Action Args
2010-07-20 02:02:38ngiesetrecipients: + ngie
2010-07-20 02:02:37ngiesetmessageid: <1279591357.64.0.139129514793.issue9311@psf.upfronthosting.co.za>
2010-07-20 02:02:35ngielinkissue9311 messages
2010-07-20 02:02:34ngiecreate