Skip to content

TypeError: Cannot create a consistent method resolution order, why the newline? #107910

Closed
@sobolevn

Description

@sobolevn

Repro:

>>> class My[X](object): ...
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <generic parameters of My>
TypeError: Cannot create a consistent method resolution
order (MRO) for bases object, Generic

Notice that there's a \n between "resolution" and "order".

This code exists for 21 years now: https://github.com/python/cpython/blame/main/Objects/typeobject.c#L2447
And it does not look anyone else is bothered :)

For me, TypeError: Cannot create a consistent method resolution order (MRO) for bases object, Generic would be a much better error message.

Opinions?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions