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

[mypyc] Fixing check for enum classes. #18178

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

advait-dixit
Copy link
Contributor

@advait-dixit advait-dixit commented Nov 23, 2024

Fixes mypyc/mypyc#1065
Fixes mypyc/mypyc#1059
Fixes mypyc/mypyc#1022

  • Checking for enum classes using is_enum flag instead of fullname of base class. That way, mypyc recognizes classes derived from IntEnum as enum classes too.
  • After fixing the above bug, test failures revealed that mypyc was sending all MRO classes to __prepare__ function. For example, for the Player test class added in this PR, mypyc was generating C code to call __prepare__ of the base class with (IntEnum, int, Enum) instead of just (IntEnum,). This bug has been fixed in classdef.py:populate_non_ext_bases.

@advait-dixit advait-dixit changed the title [mypyc] Fixing check if enum classes. [mypyc] Fixing check for enum classes. Nov 25, 2024
@advait-dixit
Copy link
Contributor Author

advait-dixit commented Nov 26, 2024

@JukkaL @hauntsaninja : This PR is ready for review. Please take a look. Sorry for multiple edits and updates. It took some tries to get all tests to pass.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Not too familiar with mypyc, but it's definitely weird that it's passing the whole MRO as bases. Looks like it's there in this PR https://github.com/mypyc/mypyc/pull/657/files

@hauntsaninja hauntsaninja merged commit 2842e8f into python:master Nov 27, 2024
13 checks passed
@advait-dixit advait-dixit deleted the fix_int_enum branch November 27, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants