gh-108851: Fix tomllib recursion tests#108853
Conversation
|
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.
Should subTest() used instead of printing out the values?
There was a problem hiding this comment.
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? |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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 <vstinner@python.org>
|
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 <vstinner@python.org>
Uh oh!
There was an error while loading. Please reload this page.