-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
bpo-38470: Fix test_compileall.test_compile_dir_maxlevels() #16789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix test_compile_dir_maxlevels() on Windows without long path support: only create 3 subdirectories instead of between 20 and 100 subdirectories. Fix also compile_dir() to use the current sys.getrecursionlimit() value as the default maxlevels value, rather than using sys.getrecursionlimit() value read at startup.
IMHO using the sys.getrecursionlimit() value read at startup is surprising, since it can be modified at runtime.
Python 3.8 used 10 as the default value of maxlevels. But the default changed to sys.getrecusionlimit() in the master branch. I don't think that it's worth it to test that the default is sys.getrecusionlimit(). -- By the way, I'm not sure about using sys.getrecusionlimit() as the default. Maybe it should be unlimited by default. I'm not sure neither why the default was 10 previously. In practice, using sys.getrecusionlimit() as the default means "unlimited": Python will raise RecursionError before the function will reach maxlevels=0. |
I also wrote a working create_long_path() which fix the check for "too long path" using importlib._bootstrap_external._write_atomic(longer_cache, b''), but honestly it looks like overkill just to test maxlevels parameter. The function becomes 51 lines long. So I chose to not propose this overcomplicated solution, but propose this way simpler approach. |
I can agree that using Edit: Confirmed the default recursion limit: Line 635 in 4d20228
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Yes, this really needed taking a step back, rather than adding to the complexity.
I ran this test through buildbot-custom
, and the bots look happy!
@aeros, compileall doesn't change the recursion limit (that could lead to crashes, yes). It only uses it (as an integer that effectively means "infinity" in this case). |
I'm not sure why anyone would need the "default recursion limit". sys.setrecursionlimit() exists because the developer knows better than Python what the limit should be. With my merged change, compileall now uses the current limit. Thanks for merging it @encukou. |
Oh I see. I had misunderstood what Victor was saying in his earlier comments. It sounded like with the proposed changes, the recursion limit would become infinite, rather than using whatever the user specified:
Between the options of using the default recursion limit and unlimited, I was in favor of using the default instead. Now I realize that he was referring to the previous version, and not the current one with the proposed changes in the PR. I completely agree though that it's far better to allow the user the specify their own limit.
Disregard that suggestion, it was only made because of my earlier misunderstanding. |
…-16789) Fix test_compile_dir_maxlevels() on Windows without long path support: only create 3 subdirectories instead of between 20 and 100 subdirectories. Fix also compile_dir() to use the current sys.getrecursionlimit() value as the default maxlevels value, rather than using sys.getrecursionlimit() value read at startup.
…-16789) Fix test_compile_dir_maxlevels() on Windows without long path support: only create 3 subdirectories instead of between 20 and 100 subdirectories. Fix also compile_dir() to use the current sys.getrecursionlimit() value as the default maxlevels value, rather than using sys.getrecursionlimit() value read at startup.
Fix test_compile_dir_maxlevels() on Windows without long path
support: only create 3 subdirectories instead of between 20 and 100
subdirectories.
Fix also compile_dir() to use the current sys.getrecursionlimit()
value as the default maxlevels value, rather than using
sys.getrecursionlimit() value read at startup.
https://bugs.python.org/issue38470