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: compileall.compile_dir loses 'optimize' parameter in recursion.
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, georg.brandl, july, r.david.murray
Priority: normal Keywords: needs review, patch

Created on 2011-02-06 11:03 by july, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
compileall.compile_dir.optimize.test.diff july, 2011-02-06 11:03 failing test (patch to test_compileall)
compileall.compile_dir.optimize.diff july, 2011-02-06 11:06 solution
Messages (4)
msg128048 - (view) Author: July Tikhonov (july) * Date: 2011-02-06 11:03
july@julynote:~/test> ls -R
.:
c.py  subdir

./subdir:
a.py  b.py
july@julynote:~/test> python3
Python 3.2rc2+ (py3k, Feb  6 2011, 13:06:04) 
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from compileall import compile_dir
>>> compile_dir('.', optimize=1)
Listing . ...
Compiling ./c.py ...
Listing ./subdir ...
Compiling ./subdir/a.py ...
Compiling ./subdir/b.py ...
1
>>> 
july@julynote:~/test> ls -R
.:
c.py  __pycache__  subdir

./__pycache__:
c.cpython-32.pyo

./subdir:
a.py  b.py  __pycache__

./subdir/__pycache__:
a.cpython-32.pyc  b.cpython-32.pyc
july@julynote:~/test>

It seems that the bug was introduced in svn revision 87019 (Add an "optimize" parameter to compile() to control the optimization level, and provide an interface to it in py_compile, compileall and PyZipFile.).

In recursion, 'optimize' parameter is lost and replaced by default -1 (optimize level of the interpreter).

Test patch added.
msg128049 - (view) Author: July Tikhonov (july) * Date: 2011-02-06 11:06
Patch added.
msg128056 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-06 12:20
Patch looks good.
msg128110 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-02-07 12:37
Thanks, fixed in r88366.
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55341
2011-02-07 12:37:36georg.brandlsetstatus: open -> closed

messages: + msg128110
resolution: fixed
nosy: georg.brandl, eric.araujo, r.david.murray, july
2011-02-06 12:20:19eric.araujosetversions: + Python 3.3
nosy: + georg.brandl, r.david.murray, eric.araujo

messages: + msg128056

keywords: + needs review
stage: patch review
2011-02-06 11:06:30julysetfiles: + compileall.compile_dir.optimize.diff

messages: + msg128049
2011-02-06 11:03:22julycreate