Uh oh!
There was an error while loading. Please reload this page.
gh-129573: Fix possible abort from non-string suggestions in calculate_suggestions/_Py_CalculateSuggestions - #130997
gh-129573: Fix possible abort from non-string suggestions in calculate_suggestions/_Py_CalculateSuggestions#130997devdanzin wants to merge 9 commits into
calculate_suggestions/_Py_CalculateSuggestions#130997Conversation
vstinner
commented
Mar 10, 2025
test_traceback is failing on the CI. |
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
Apr 18, 2025
@devdanzin: Tests are failing on your PR, and you didn't sign the CLA. What's the status of this PR? |
devdanzin
commented
Apr 18, 2025
I'm sorry, I've left this one fall behind. Would you like to take it over? I have signed the CLA and even contributed some trivial code, I'll wait to see if it's a CLA bot issue or my CLA status changed to unverified somehow. |
| def test_suggestions_do_not_trigger_with_non_string_candidates(self): | ||
| def run_module_code(): | ||
| import runpy | ||
| runpy._run_module_code("blech", {0: "", "bluch": ""}, "") |
There was a problem hiding this comment.
| runpy._run_module_code("blech", {0: "", "bluch": ""}, "") | |
| # non-string global variable | |
| runpy._run_module_code("blech", {0: "", "bluch": ""}, "") |
| self.assertRaises( | ||
| TypeError, | ||
| _suggestions._generate_suggestions, |
There was a problem hiding this comment.
_suggestions._generate_suggestions() checks if all elements are strings before calling _Py_CalculateSuggestions(). So this test doesn't check changed code.
This PR is stale because it has been open for 30 days with no activity. |
This PR adds a simple check that suggestion candidates are strings in
calculate_suggestions(3.12)/_Py_CalculateSuggestions(main), avoiding an abort in debug builds from code like below:The abort only happens in 3.12, because the code in main checks for non-string candidates in
_suggestions__generate_suggestions_impl. However, since the affected code is still present in main, this PR is against that branch.In main, the code above exits the new REPL, which will be reported as a new issue with associated PR.
Found using fusil by @vstinner.
_PyUnicode_Equalfromcalculate_suggestionswith non-string candidate #129573