gui: Solve a recursion error in gui/wxpython/lmgr/giface.py #4514
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4485 (comment)
The RecursionError is probably caused by #4453, where one of these RecursionErrors was caught in tests, and fixed in a commit in that PR (f7874f6). The exact reason causing the failure wasn't known, so fixing the method
mapsets
that might have been called elsewhere was the correct thing. There wasn't the same pattern in the PR to be fixed.However, with that comment, it is now clear that it is calling
list()
inside__len__()
of that same object that is problematic. After reading a bit, the list constructor gets the length or the length hint (when available) as an optimization to allocate memory.https://stackoverflow.com/questions/41474829/why-does-list-ask-about-len https://github.com/python/cpython/blob/67f6e08147bc005e460d82fcce85bf5d56009cf5/Objects/listobject.c#L1164
I've worked on creating a repro case and filed an issue to Ruff astral-sh/ruff#13752 about that, as the explanations on why the rule was considered an unsafe fix was misleading, as it only concerned lost comments.