| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
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). |
Sorry, something went wrong.
|
The test_tomllib failure can be reproduced on Linux by reducing the recursion limit. Use this patch: diff --git a/Lib/test/test_tomllib/test_misc.py b/Lib/test/test_tomllib/test_misc.py index a477a219fd..43357f2064 100644 --- a/Lib/test/test_tomllib/test_misc.py +++ b/Lib/test/test_tomllib/test_misc.py @@ -10,6 +10,8 @@ import tempfile import unittest +sys.setrecursionlimit(250) + from . import tomllib On the main branch, I reproduce the issue: $ ./python -m test test_tomllib -v (...) ====================================================================== ERROR: test_inline_array_recursion_limit (test.test_tomllib.test_misc.TestMiscellaneous.test_inline_array_recursion_limit) ---------------------------------------------------------------------- (...) RecursionError: maximum recursion depth exceeded ====================================================================== ERROR: test_inline_table_recursion_limit (test.test_tomllib.test_misc.TestMiscellaneous.test_inline_table_recursion_limit) ---------------------------------------------------------------------- (...) RecursionError: maximum recursion depth exceeded (...) With this PR and the patch to trigger the bug: test_tomllib pass successfully. |
Sorry, something went wrong.
| # 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?
Sorry, something went wrong.
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.
Sorry, something went wrong.
* 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().
|
I rebased my PR and I revert the sys.setrecursionlimit(). The sys.setrecursionlimit() change was fun to do, play with the bare minimum. But it introduces a weird behavior (you can no longer call any Python function, not great.) Instead of I changed the support.infinite_recursion() minimum to 3, instead of 2. In practice, this function should be called at least with 50 (default is 100 with my change). |
Sorry, something went wrong.
|
@brettcannon: Would you mind to review the updated PR? |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
You may also add simple docstrings for new functions. Just one line would be enough.
Sorry, something went wrong.
|
Sorry, something went wrong.
I added docstrings to the 2 newly added test.support functions. |
Sorry, something went wrong.
|
There's a new commit after the PR has been approved. @serhiy-storchaka: please review the changes made to this pull request. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, something went wrong.
|
Sorry, @vstinner, I could not cleanly backport this to 3.11 due to a conflict. |
Sorry, something went wrong.
* 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. |
Sorry, something went wrong.
* 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. |
Sorry, something went wrong.
|
Thanks for the review @brettcannon and @serhiy-storchaka. I will try to keep an eye on the WASI buildbots ;-) |
Sorry, something went wrong.
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! |
Sorry, something went wrong.
|
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 sys.getrecursionlimit to test.pythoninfo. On WASI, the limit is lower, as you can now see on test.pythoninfo: sys.getrecursionlimit: 600 On other platforms, the default is 1,000 frames: $ make pythoninfo|grep getrecursionlimit sys.getrecursionlimit: 1000 |
Sorry, something went wrong.
|
Oh, I was sure that I removed #self.assertEqual(available, 2) commented code from test_support.py but it back from death in the merged commit! Well, I will remove it in a following change :-) |
Sorry, something went wrong.
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>
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.