Uh oh!
There was an error while loading. Please reload this page.
gh-108851: Fix tomllib recursion tests - #108853
Conversation
vstinner
commented
Sep 3, 2023
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). |
vstinner
commented
Sep 3, 2023
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. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| # 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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
* 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
a1b3414Comparevstinner
commented
Sep 5, 2023
I rebased my PR and I revert the The |
vstinner
commented
Sep 5, 2023
@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.
vstinner
commented
Sep 6, 2023
|
vstinner
commented
Sep 6, 2023
I added docstrings to the 2 newly added test.support functions. |
bedevere-bot
commented
Sep 6, 2023
There's a new commit after the PR has been approved. @serhiy-storchaka: please review the changes made to this pull request. |
miss-islington
commented
Sep 6, 2023
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
miss-islington
commented
Sep 6, 2023
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
miss-islington
commented
Sep 6, 2023
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>
bedevere-bot
commented
Sep 6, 2023
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)
bedevere-bot
commented
Sep 6, 2023
GH-109013 is a backport of this pull request to the 3.11 branch. |
vstinner
commented
Sep 6, 2023
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)
brettcannon
commented
Sep 6, 2023
Thanks for the fix! |
vstinner
commented
Sep 7, 2023
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: |
vstinner
commented
Sep 8, 2023
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.