Uh oh!
There was an error while loading. Please reload this page.
gh-116767: fix crash on 'async with' with many context managers - #118348
Conversation
encukou
commented
Apr 29, 2024
Thank you! I can't say I follow all of what's happening here, but I have a better picture now :) This is technically backwards incompatible -- the limit is decreased even for plain asyncdeft():
withc,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c: cdefg():
withc,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c: yieldShould |
iritkatriel
commented
Apr 29, 2024
We could, though this maximum static depth is not documented anywhere and I seriously doubt anyone hits it. |
iritkatriel
commented
Apr 30, 2024
I made the change, it changes semantics the other way (allowing one more nested level in the non-generator case). I think that's ok. (The compiler could distinguish the cases and use a different limit for each, but I don't think it's worth the added complexity). |
encukou
left a comment
There was a problem hiding this comment.
Thank you!
I guess the kind of use-case that would hit this is auto-generated code. Bumping to 21 is easier than researching if someone does that.
Thanks @iritkatriel for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @iritkatriel and @encukou, I could not cleanly backport this to |
bedevere-bot
commented
May 1, 2024
|
…pythonGH-118348) Account for `add_stopiteration_handler` pushing a block for `async with`. To allow generator functions that previously almost hit the `CO_MAXBLOCKS` limit by nesting non-async blocks, the limit is increased by 1. This increase allows one more block in non-generator functions. (cherry picked from commit c1bf487)
GH-118477 is a backport of this pull request to the 3.12 branch. |
GH-118348) (#118477) gh-116767: fix crash on 'async with' with many context managers (GH-118348) Account for `add_stopiteration_handler` pushing a block for `async with`. To allow generator functions that previously almost hit the `CO_MAXBLOCKS` limit by nesting non-async blocks, the limit is increased by 1. This increase allows one more block in non-generator functions. (cherry picked from commit c1bf487)
…pythonGH-118348) Account for `add_stopiteration_handler` pushing a block for `async with`. To allow generator functions that previously almost hit the `CO_MAXBLOCKS` limit by nesting non-async blocks, the limit is increased by 1. This increase allows one more block in non-generator functions.
Fixes#116767.