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.

classification
Title: .pyc files are set executable if the .py file is too
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.6
process
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 2022-04-11 14:56 by admin. 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 > test.py
$ chmod u+x test.py
$ 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 > test.py
    Steven> $ chmod u+x test.py
    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 ./test.py 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.

Skip
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.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51265
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