Skip to content

3.11 unexpected multiple inheritance method lookup difference? #94601

@justvanrossum

Description

@justvanrossum

Bug report

The following snippet has a different output on Python 3.11.0b3 than on <= 3.10:

import enum

class StrMixin:
    def __str__(self):
        return f"__str__ from {self.__class__.__name__} {self.value}"

class MyEnumTuple(tuple, StrMixin, enum.Enum):
	FIELD = (1, 0)

x = MyEnumTuple((1, 0))
print(x)

On 3.10 and earlier it outputs:

__str__ from EnumMixin (1, 0)

On 3.11.0b3 it outputs this:

MyEnumTuple.FIELD

My environment

  • CPython versions tested on: 3.11.0b3, 3.10.1, 3.9.7
  • Operating system and architecture: macOS 10.15.7, x86_64

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions