-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-108851: Fix tomllib recursion tests #108853
Conversation
vstinner
commented
Sep 3, 2023
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- sys.setrecursionlimit() now allows setting the limit to the current recursion depth.
- Add get_recursion_available() and get_recursion_depth() functions to the test.support module.
- Change infinite_recursion() default max_depth from 75 to 100.
- Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit.
- Issue: test_tomllib.test_inline_array_recursion_limit() failed on wasm32-wasi 3.11 buildbot #108851
This PR combines 3 changes at once. IMO it's better to change all of them at the same time to ease backports, rather than having 3 commits (more work for little benefits). |
The test_tomllib failure can be reproduced on Linux by reducing the recursion limit. Use this patch:
On the main branch, I reproduce the issue:
With this PR and the patch to trigger the bug: test_tomllib pass successfully. |
# it can raise RecursionError | ||
return | ||
get_depth = support.get_recursion_depth() | ||
print(f"test_recursive: {depth}/{limit}: " |
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.
Should subTest()
used instead of printing out the values?
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.
This is a script run by test_get_recursion_depth(). You should not see the output unless the test crash or fails. It's not written with unittest.
* Add get_recursion_available() and get_recursion_depth() functions to the test.support module. * Change infinite_recursion() default max_depth from 75 to 100. * Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit. * test.pythoninfo logs sys.getrecursionlimit() * Enhance test_sys tests on sys.getrecursionlimit() and sys.setrecursionlimit().
b0104a7
to
a1b3414
Compare
I rebased my PR and I revert the The |
@brettcannon: Would you mind to review the updated PR? |
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.
LGTM.
You may also add simple docstrings for new functions. Just one line would be enough.
|
I added docstrings to the 2 newly added test.support functions. |
There's a new commit after the PR has been approved. @serhiy-storchaka: please review the changes made to this pull request. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, @vstinner, I could not cleanly backport this to |
* Add get_recursion_available() and get_recursion_depth() functions to the test.support module. * Change infinite_recursion() default max_depth from 75 to 100. * Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit. * test.pythoninfo logs sys.getrecursionlimit(). * Enhance test_sys tests on sys.getrecursionlimit() and sys.setrecursionlimit(). (cherry picked from commit 8ff1142) Co-authored-by: Victor Stinner <[email protected]>
GH-109012 is a backport of this pull request to the 3.12 branch. |
* Add get_recursion_available() and get_recursion_depth() functions to the test.support module. * Change infinite_recursion() default max_depth from 75 to 100. * Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit. * test.pythoninfo logs sys.getrecursionlimit(). * Enhance test_sys tests on sys.getrecursionlimit() and sys.setrecursionlimit(). Backport notes: * Set support.infinite_recursion() minimumum to 4 frames. * test_support.test_get_recursion_depth() uses limit-2, apparently f-string counts for 2 frames in Python 3.11. * test_sys.test_setrecursionlimit_to_depth() tests depth+2 instead of depth+1. (cherry picked from commit 8ff1142)
* Add get_recursion_available() and get_recursion_depth() functions to the test.support module. * Change infinite_recursion() default max_depth from 75 to 100. * Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit. * test.pythoninfo logs sys.getrecursionlimit(). * Enhance test_sys tests on sys.getrecursionlimit() and sys.setrecursionlimit(). Backport notes: * Set support.infinite_recursion() minimum to 4 frames. * test_support.test_get_recursion_depth() uses limit-2, apparently f-string counts for 2 frames in Python 3.11. * test_sys.test_setrecursionlimit_to_depth() tests depth+2 instead of depth+1. (cherry picked from commit 8ff1142)
GH-109013 is a backport of this pull request to the 3.11 branch. |
Thanks for the review @brettcannon and @serhiy-storchaka. I will try to keep an eye on the WASI buildbots ;-) |
gh-108851: Fix tomllib recursion tests (#108853) * Add get_recursion_available() and get_recursion_depth() functions to the test.support module. * Change infinite_recursion() default max_depth from 75 to 100. * Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit. * test.pythoninfo logs sys.getrecursionlimit(). * Enhance test_sys tests on sys.getrecursionlimit() and sys.setrecursionlimit(). Backport notes: * Set support.infinite_recursion() minimum to 4 frames. * test_support.test_get_recursion_depth() uses limit-2, apparently f-string counts for 2 frames in Python 3.11. * test_sys.test_setrecursionlimit_to_depth() tests depth+2 instead of depth+1. (cherry picked from commit 8ff1142)
Thanks for the fix! |
The fix works as expected: wasm32-wasi 3.11917 buildbot is back to green (success). first successful build: https://buildbot.python.org/all/#/builders/1047/builds/908 By the way, I added
On other platforms, the default is 1,000 frames:
|
Oh, I was sure that I removed |
gh-108851: Fix tomllib recursion tests (GH-108853) * Add get_recursion_available() and get_recursion_depth() functions to the test.support module. * Change infinite_recursion() default max_depth from 75 to 100. * Fix test_tomllib recursion tests for WASI buildbots: reduce the recursion limit and compute the maximum nested array/dict depending on the current available recursion limit. * test.pythoninfo logs sys.getrecursionlimit(). * Enhance test_sys tests on sys.getrecursionlimit() and sys.setrecursionlimit(). (cherry picked from commit 8ff1142) Co-authored-by: Victor Stinner <[email protected]>