Title: .pyc files are set executable if the .py file is too
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.6
Status: closed Resolution: out of date
Dependencies: Superseder: Python 2.6 makes .pyc/.pyo bytecode files executable
View: 6070
Assigned To: Nosy List: r.david.murray, skip.montanaro, steven.daprano
Priority: normal Keywords:

Created on 2009-09-29 06:57 by steven.daprano, last changed 2009-09-29 12:15 by r.david.murray. This issue is now closed.

Messages (3)
msg93254 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2009-09-29 06:57
In Python 2.6, .pyc files inherit the executable bit from their .py 
file. This can lead to strangeness:

$ echo pass >
$ chmod u+x
$ python2.6 -c "import test"
$ ls -l test.pyc
-rwxrw-r-- 1 steve steve 94 2009-09-29 16:54 test.pyc
$ ./test.pyc
: command not found ��
msg93281 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2009-09-29 11:51
Steven> $ echo pass >
    Steven> $ chmod u+x
    Steven> $ python2.6 -c "import test"
    Steven> $ ls -l test.pyc
    Steven> -rwxrw-r-- 1 steve steve 94 2009-09-29 16:54 test.pyc
    Steven> $ ./test.pyc
    Steven> : command not found   

And if you try ./ I presume you also get an error in this trivial
case.  If your .py file is not meant to be executed, why set the execute
bit?  I do agree it's a little strange to also set the execute bit on the
.pyc file though.

msg93283 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-09-29 12:15
This is a duplicate of issue 6070, and has been fixed.
Date User Action Args
2009-09-29 12:15:12r.david.murraysetstatus: open -> closed
priority: normal
superseder: Python 2.6 makes .pyc/.pyo bytecode files executable

nosy: + r.david.murray
messages: + msg93283
resolution: out of date
stage: resolved
2009-09-29 11:51:40skip.montanarosetnosy: + skip.montanaro
messages: + msg93281
2009-09-29 06:57:07steven.dapranocreate