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 brett.cannon
Recipients Arfrever, brett.cannon, eric.snow, ncoghlan
Date 2013-02-18.19:02:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361214137.85.0.384747833016.issue17222@psf.upfronthosting.co.za>
In-reply-to
Content
So py_compile always replaced the file, even in Python 3.3: http://hg.python.org/cpython/file/79ea59b394bf/Lib/py_compile.py#l141 (this is why I changed the title of the bug). What did change, though, is that py_compile now writes bytecode files just as import does, which means copying the file permissions of the source file for the bytecode file. E.g. if you listed the permissions for test.py in your example output I bet it's -rw-r----- just like what /dev/null ended up with.

I'm not going to change this as this is very much on purpose for security reasons; it's more of a long-standing bug that py_compile never used the proper permissions than it is changing the semantics to what they are today. Since py_compile is for compiling and writing out source code it should match what import does (if you are doing this to verify the file will parse properly, which is what writing to /dev/null suggests, it would be more accurate to just pass the raw source code through the AST module and make sure no exceptions are raised, else just write into the /tmp directory and let the OS clean up).

What I will do, though, it document this fact in the docs with a "Changed in Python 3.4" note and in What's New since people should be aware of it.
History
Date User Action Args
2013-02-18 19:02:17brett.cannonsetrecipients: + brett.cannon, ncoghlan, Arfrever, eric.snow
2013-02-18 19:02:17brett.cannonsetmessageid: <1361214137.85.0.384747833016.issue17222@psf.upfronthosting.co.za>
2013-02-18 19:02:17brett.cannonlinkissue17222 messages
2013-02-18 19:02:17brett.cannoncreate