Skip to content

Using functools.partial to make functions not considered as methods when given as enum values no longer works #125316

@bluthej

Description

@bluthej

Bug report

Bug description:

On python 3.10-3.12, the following snippet prints True, while on Python 3.13.0 it prints False:

from enum import Enum
from functools import partial


def a():
    pass


def b():
    pass


class MyCallables(Enum):
    A = a
    B = partial(b)


print(MyCallables.B in MyCallables)

This is because MyCallables.B is considered to be functools.partial(<function b at 0x756d7f0065c0>) on 3.13.0, when it used to be <MyCallables.B: functools.partial(<function b at 0x71f7cbc407c0>)> before.

This is something I've been using to allow function values in enums not to be considered methods, which I most likely got from this thread. In the example above, A would always be considered a method.

It seems like on 3.13.0, the "wrapper class" approach is the only one that works.

CPython versions tested on:

3.10, 3.11, 3.12, 3.13

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy