Skip to content

3.11 unexpected multiple inheritance method lookup difference? #94601

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

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.11only security fixes
    3.12only security fixes
    on Jul 6, 2022
  2. added a commit that references this issue on Jul 18, 2022
  3. added 2 commits that reference this issue on Jul 18, 2022
  4. hauntsaninja commented on Oct 12, 2022

    @hauntsaninja
    Contributor

    Thanks for reporting this! Looks like it's been fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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