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.

Title: maxlevels -1 on compileall for unlimited recursion
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, Sworddragon, benjamin.peterson, berker.peksag, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2013-11-16 20:40 by Sworddragon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
compileall.patch Claudiu.Popa, 2013-11-21 22:17 review
issue19628.patch Claudiu.Popa, 2014-03-11 21:23 Minor fixes. review
issue19628_1.patch Claudiu.Popa, 2014-04-11 17:38 review
Messages (10)
msg203081 - (view) Author: (Sworddragon) Date: 2013-11-16 20:40
All functions of compileall are providing a maxlevels argument which defaults to 10. But it is currently not possible to disable this recursion limitation. Maybe it would be useful to have a special value like -1 to disable this limitation and allow to compile in an infinite amount of subdirectories.

Also I'm noticing maxlevels is the only argument which is not available on command line. Does it default there to 10 too? Maybe it would be useful if it could be configured too (in this case it could theoretically replace -l).
msg203685 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2013-11-21 22:17
Here's a patch which adds support for controlling the maxlevels on command line. Currently, compileall uses a binary choice, either we don't process subdirectories or we process at most 10 subdirectories. This seems to be the case since its inception, in 
1828 (b464e1d0b2fb) New way of generating .pyc files, thanks to Sjoerd.
Guido van Rossum <>
1994-08-29 10:52:58 +0000 (1994-08-29)

The patch adds a new command option, -r, where `-r 0` is equivalent to specifying -l. I guess we can't modify -l to actually control the maxlevels, due to backward compatibility concerns.
msg215897 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-04-10 18:25
Ping. :) Can someone review this patch, please?
msg215935 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-04-11 17:38
Added patch which addresses the comments of Berker Peksag. Thanks for the review!
msg221619 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-06-26 17:23
Do we really want to allow infinite recursion (say a symbolic link loop)?
msg221621 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-06-26 17:26
Ah, bad font, I thought the -l was a -1.  I see you aren't adding the infinite recursion, the just ability to control the maximum.  The patch looks good to me.
msg225541 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-08-19 20:53
Why can't we just reuse the "-l" option?
msg225542 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-08-19 21:05
Backward compatibility reasons, I guess. compileall -l completely deactivates the recursion, so using -l for controlling the number of levels seems to overwrite its original meaning.
msg225544 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-19 21:13
New changeset a62368778d6c by Benjamin Peterson in branch 'default':
allow recursion depth to be specified (closes #19628)
msg253591 - (view) Author: (Sworddragon) Date: 2015-10-28 08:27
I'm wondering what the recursion limit is if -l and -r are not given. Does it default to 10 too or is there no limit? If the first is the case maybe this should also get documented.
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63827
2015-10-28 08:27:28Sworddragonsetmessages: + msg253591
2014-08-19 21:13:36python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg225544

resolution: fixed
stage: commit review -> resolved
2014-08-19 21:05:55Claudiu.Popasetmessages: + msg225542
2014-08-19 20:53:41benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg225541
2014-08-13 09:24:17berker.peksagsetnosy: + berker.peksag
2014-06-26 17:26:04r.david.murraysetmessages: + msg221621
stage: patch review -> commit review
2014-06-26 17:23:03r.david.murraysetmessages: + msg221619
2014-06-26 17:06:40Claudiu.Popasetnosy: + r.david.murray
2014-06-16 10:44:56Claudiu.Popasetstage: patch review
2014-04-11 17:38:07Claudiu.Popasetfiles: + issue19628_1.patch

messages: + msg215935
2014-04-10 18:25:12Claudiu.Popasetmessages: + msg215897
2014-03-11 21:23:09Claudiu.Popasetfiles: + issue19628.patch
versions: + Python 3.5, - Python 3.4
2013-11-21 22:17:40Claudiu.Popasetversions: + Python 3.4, - Python 2.7, Python 3.3
2013-11-21 22:17:22Claudiu.Popasetfiles: + compileall.patch

nosy: + Claudiu.Popa
messages: + msg203685

keywords: + patch
2013-11-16 20:40:50Sworddragoncreate