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

fix enum.Flag empty check #1167

Merged
merged 1 commit into from
Jan 26, 2025
Merged

fix enum.Flag empty check #1167

merged 1 commit into from
Jan 26, 2025

Conversation

b10902118
Copy link
Contributor

Description

Fix the permission checks in Section by using enum.Flag.__bool__. For enum.Flag, != 0 always returns True, as the test below.

import enum

class Permission(enum.Flag):
    NONE = 0
    EXECUTE = 1
    WRITE = 2
    READ = 4
    ALL = 7

p = Permission(0)
print(p, p != 0)  # Permission.NONE True

The fixed functions are rarely called. I found this when porting Section to llef. I also have checked all != 0 and found no similar error.

  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • If my change adds new code, adequate tests have been added.
  • I have read and agree to the CONTRIBUTING document.

Copy link

🤖 Coverage update for bca5b62 🟢

Old New
Commit ed10244 bca5b62
Score 71.0959% 71.0959% (0)

@Grazfather
Copy link
Collaborator

Strange behaviour. But I confirmed. Thank you!

@hugsy hugsy merged commit 7638efe into hugsy:main Jan 26, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants