Skip to content

Abort from type checking mismatch between _suggestions__generate_suggestions_impl and _Py_CalculateSuggestions #131936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
devdanzin opened this issue Mar 31, 2025 · 2 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@devdanzin
Copy link
Contributor

devdanzin commented Mar 31, 2025

Crash report

What happened?

This is a silly one: _suggestions__generate_suggestions_impl, which checks whether the candidates is a list or subclass, calls _Py_CalculateSuggestions, which checks whether candidates is an exact list instance with an assert that fails if _suggestions._generate_suggestions receives an instance of a list subclass.

import _suggestions
class L(list): pass
_suggestions._generate_suggestions(L(), "")
python: Python/suggestions.c:132: _Py_CalculateSuggestions: Assertion `PyList_CheckExact(dir)' failed.
Aborted (core dumped)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows, Linux

Output from running 'python -VV' on the command line:

Python 3.14.0a6+ (heads/main:be2d2181e62, Mar 31 2025, 07:30:17) [GCC 11.4.0]

Linked PRs

@devdanzin devdanzin added the type-crash A hard crash of the interpreter, possibly with a core dump label Mar 31, 2025
@devdanzin devdanzin changed the title Abort from type checking mismatch in between _suggestions__generate_suggestions_impl and _Py_CalculateSuggestions Abort from type checking mismatch between _suggestions__generate_suggestions_impl and _Py_CalculateSuggestions Mar 31, 2025
@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Mar 31, 2025
@ZeroIntensity
Copy link
Member

I'm pretty sure we can relax that assertion. I don't see why it has to be exactly a list.

@vstinner
Copy link
Member

Fixed by change 511d344.

vstinner pushed a commit that referenced this issue Mar 31, 2025
…ions` (GH-131945) (#131949)

gh-131936: Strengthen check in `_suggestions._generate_suggestions` (GH-131945)
(cherry picked from commit 511d344)

Co-authored-by: Peter Bierma <[email protected]>
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

4 participants