Skip to content
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

[JIT] Skip builtins while enumerating class methods #91805

Closed
wants to merge 2 commits into from

Commits on Jan 6, 2023

  1. [JIT] Skip builtins while enumerating class methods

    This is needed to support `enum.Enum` derived classes in Python-3.11
    that adds `_new_member_` to classdict, see:
    https://github.com/python/cpython/blob/15c44789bb125b93e96815a336ec73423c47508e/Lib/enum.py#L529
    
    Following snippet illustrates the problem with the previous iteration of
    the code on 3.11:
    ```python
    from enum import Enum
    import inspect
    
    class Color(Enum):
        RED = 1
        GREEN = 2
    
    def print_routines(cls):
        print(cls.__name__)
        for name in cls.__dict__:
            fn = getattr(cls, name)
            if inspect.isroutine(fn):
                print(name, fn, f"has_globals: {hasattr(fn, '__globals__')}")
    
    print_routines(Color)
    ```
    malfet committed Jan 6, 2023
    Configuration menu
    Copy the full SHA
    138ceec View commit details
    Browse the repository at this point in the history
  2. Pacify lint

    malfet committed Jan 6, 2023
    Configuration menu
    Copy the full SHA
    cda01cd View commit details
    Browse the repository at this point in the history