classification
Title: compileall -f doesn't force to write bytecode files
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Sworddragon, ned.deily, python-dev, r.david.murray, vajrasky
Priority: normal Keywords: easy, patch

Created on 2013-11-09 06:14 by Sworddragon, last changed 2013-12-16 01:58 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
compileall_force.patch vajrasky, 2013-11-09 10:57 review
compileall_force_v2.patch vajrasky, 2013-11-10 09:40 review
compileall_force_v3.patch vajrasky, 2013-11-10 10:03 review
Messages (8)
msg202463 - (view) Author: (Sworddragon) Date: 2013-11-09 06:14
The force-option from compileall seems not to rebuild the bytecode files if they already exist. Here is an example of 2 calls:

root@ubuntu:~# python3 -m compileall -f
Skipping current directory
Listing '/usr/lib/python3.3'...
Compiling '/usr/lib/python3.3/__phello__.foo.py'...
Compiling '/usr/lib/python3.3/_compat_pickle.py'...
Compiling '/usr/lib/python3.3/_dummy_thread.py'...
...
Compiling '/usr/lib/python3.3/webbrowser.py'...
Compiling '/usr/lib/python3.3/xdrlib.py'...
Compiling '/usr/lib/python3.3/zipfile.py'...
Listing '/usr/lib/python3.3/plat-x86_64-linux-gnu'...
Listing '/usr/lib/python3.3/lib-dynload'...
Listing '/usr/local/lib/python3.3/dist-packages'...
Listing '/usr/lib/python3/dist-packages'...
root@ubuntu:~# python3 -m compileall -f
Skipping current directory
Listing '/usr/lib/python3.3'...
Listing '/usr/lib/python3.3/plat-x86_64-linux-gnu'...
Listing '/usr/lib/python3.3/lib-dynload'...
Listing '/usr/local/lib/python3.3/dist-packages'...
Listing '/usr/lib/python3/dist-packages'...
msg202466 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-11-09 07:59
Looking at the compileall module, it appears that -f and options other than -b have never (or, at least, for a long time, not) been supported when directories or files are not supplied and it defaults to <directories from sys.path>.  Note the call in main() to compile_path vs those to compile_file or compile_dir.  I'm not sure if there was a good reason for the difference but it seems like a bug now.  Would you care to work on a patch and/or tests?
msg202479 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-09 10:57
Attached the patch to fix the problem. I did not modify the unit test because the bug was located in the __main__ part of Lib/compileall.
msg202490 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-11-09 17:56
test_compileall has fairly extensive tests of the command line behavior, added when we refactored from optparse to argparse.  So a test should be added for this case.
msg202517 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-10 09:40
Ah, I missed that. I made this assumption because when I executed other modules manually, they were there just for testing functionality (such as shlex and aifc).

Added test.
msg202518 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-10 10:03
Tidied up the test.
msg206273 - (view) Author: Roundup Robot (python-dev) Date: 2013-12-16 01:57
New changeset 6afad4f29249 by R David Murray in branch '3.3':
#19532: make compileall with no file/dir args respect -f and -q.
http://hg.python.org/cpython/rev/6afad4f29249

New changeset 0e07ab605e0b by R David Murray in branch 'default':
Merge: #19532: make compileall with no file/dir args respect -f and -q.
http://hg.python.org/cpython/rev/0e07ab605e0b
msg206274 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-12-16 01:58
Thanks, Vajrasky.

I did not backport this to 2.7 because the code is different and we don't have proper tests there, so the chance of breaking something is higher than the benefit of fixing it.
History
Date User Action Args
2013-12-16 01:58:23r.david.murraysetstatus: open -> closed
versions: - Python 2.7
messages: + msg206274

resolution: fixed
stage: needs patch -> resolved
2013-12-16 01:57:06python-devsetnosy: + python-dev
messages: + msg206273
2013-11-10 10:03:55vajraskysetfiles: + compileall_force_v3.patch

messages: + msg202518
2013-11-10 09:40:49vajraskysetfiles: + compileall_force_v2.patch

messages: + msg202517
2013-11-09 17:56:18r.david.murraysetnosy: + r.david.murray
messages: + msg202490
2013-11-09 10:57:07vajraskysetfiles: + compileall_force.patch

nosy: + vajrasky
messages: + msg202479

keywords: + patch
2013-11-09 07:59:16ned.deilysetversions: + Python 2.7, Python 3.4
nosy: + ned.deily

messages: + msg202466

keywords: + easy
stage: needs patch
2013-11-09 06:14:31Sworddragoncreate