René's URL Explorer Experiment


Title: gh-121291: Respect mixin bitwise-operator overrides on Flag subclasses by SomSamantray · Pull Request #155862 · python/cpython · GitHub

Open Graph Title: gh-121291: Respect mixin bitwise-operator overrides on Flag subclasses by SomSamantray · Pull Request #155862 · python/cpython

X Title: gh-121291: Respect mixin bitwise-operator overrides on Flag subclasses by SomSamantray · Pull Request #155862 · python/cpython

Description: EnumType.__new__ (Lib/enum.py) installs Flag's __or__/__and__/__xor__/__ror__/__rand__/__rxor__/__invert__ onto every Flag subclass whenever the name isn't in the subclass's own class body — but that check never looked at what a mixin base actually resolved to, so class MyFlag(Mixin, Flag) silently lost the mixin's own operator overrides to Flag's defaults. The __repr__/__str__/__format__/__reduce_ex__ block a few lines above already handles this correctly (checking whether the class's real MRO-resolved method is still the type default before overwriting); this gives the Flag-operator loop the same MRO-aware check. The check also has to distinguish a mixin's own override from a mixed-in data type's raw operator (e.g. int.__or__ for IntFlag) — an earlier version of this fix compared only against Flag's own method and broke every IntFlag combination (Color.RED | Color.BLUE silently returned a plain int instead of a boxed IntFlag), caught by running the full test_enum suite including the Doc/howto/enum.rst doctests. Lib/test/test_enum.py gets a regression test in both OldTestFlag and OldTestIntFlag covering: a mixin's override winning over Flag's default (forward and reflected forms), dunders the mixin didn't touch still getting Flag's own, and the IntFlag/int regression case. Full suite: 1091 tests pass, 0 failures. One known scope boundary, called out during review: when the overriding mixin is itself the class selected as member_type (e.g. a custom int subclass that also overrides __or__), the identity check still can't tell that apart from the raw data-type operator — the same limitation the pre-existing __repr__/__str__ block already has. Fixing that would need a heavier MRO/__dict__-walk redesign touching both blocks; out of scope here. Fixes #121291. Issue: gh-121291

Open Graph Description: EnumType.__new__ (Lib/enum.py) installs Flag's __or__/__and__/__xor__/__ror__/__rand__/__rxor__/__invert__ onto every Flag subclass whenever the name isn't in the subclass's own class b...

X Description: EnumType.__new__ (Lib/enum.py) installs Flag's __or__/__and__/__xor__/__ror__/__rand__/__rxor__/__invert__ onto every Flag subclass whenever the name isn't in the subclass's...

Opengraph URL: https://github.com/python/cpython/pull/155862

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:79f575cb-878c-8b40-c3ee-eefff7f1f7ac
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8058:12D2BD:43464A:5B75C5:6AED183B
html-safe-nonce6fd71762b92f2dba444a4343e0e01ed4d80c9c0705d73c4916a6baefc00cee15
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDU4OjEyRDJCRDo0MzQ2NEE6NUI3NUM1OjZBRUQxODNCIiwidmlzaXRvcl9pZCI6IjQ5OTEyNzUxMzUzNTI1MTA1MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaccf9bfc1df2aa4c4a92dd0da69f4903271b11253a6bb121e753018c83d62e4844
hovercard-subject-tagpull_request:4287346988
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/155862/files
twitter:imagehttps://avatars.githubusercontent.com/u/92726151?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/92726151?s=400&v=4
og:image:altEnumType.__new__ (Lib/enum.py) installs Flag's __or__/__and__/__xor__/__ror__/__rand__/__rxor__/__invert__ onto every Flag subclass whenever the name isn't in the subclass's own class b...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None120085d0bcec1f427e3ab45302c8b95f873d26ad21984dc86d62ab2c10158f41
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee12fd03aa775dceadc5a793c3a0791e43ca256bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/155862/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F155862%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F155862%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/155862/files
Reloadhttps://github.com/python/cpython/pull/155862/files
Reloadhttps://github.com/python/cpython/pull/155862/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.3k (2.3k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
ethanfurmanhttps://github.com/ethanfurman
python:mainhttps://github.com/python/cpython/tree/main
SomSamantray:gh-121291-enum-flag-mixin-operatorshttps://github.com/SomSamantray/cpython/tree/gh-121291-enum-flag-mixin-operators
Conversation 0 https://github.com/python/cpython/pull/155862
Commits 6 https://github.com/python/cpython/pull/155862/commits
Checks 53 https://github.com/python/cpython/pull/155862/checks
Files changed https://github.com/python/cpython/pull/155862/files
Please reload this pagehttps://github.com/python/cpython/pull/155862/files
gh-121291: Respect mixin bitwise-operator overrides on Flag subclasses https://github.com/python/cpython/pull/155862/files#top
Show all changes 6 commits https://github.com/python/cpython/pull/155862/files
b3fbdb6 gh-121291: respect mixin-defined bitwise operators on Flag subclasses SomSamantray Aug 15, 2026 https://github.com/python/cpython/pull/155862/commits/b3fbdb6206442f3505c63c0695ff9d135051564e
eea42a8 gh-121291: add regression tests for Flag/IntFlag mixin operators SomSamantray Aug 15, 2026 https://github.com/python/cpython/pull/155862/commits/eea42a81b159fab2412eb0bef41f45b064d5fa55
e51888d gh-121291: add NEWS entry for Flag mixin operator fix SomSamantray Aug 15, 2026 https://github.com/python/cpython/pull/155862/commits/e51888d4278dc87f01599b07951b0fad3d44a05a
c8cbf38 test: reuse existing self.Color fixture in IntFlag mixin test SomSamantray Aug 15, 2026 https://github.com/python/cpython/pull/155862/commits/c8cbf38c9ea03e7c528ae8417171f3bc145024a7
a908741 test: cover __ror__/__rand__/__rxor__ in Flag mixin operator test SomSamantray Aug 15, 2026 https://github.com/python/cpython/pull/155862/commits/a9087414e6f5187fe1406f1ad88563b41d455b77
070ec61 Merge branch 'main' into gh-121291-enum-flag-mixin-operators SomSamantray Aug 29, 2026 https://github.com/python/cpython/pull/155862/commits/070ec61c706a30ce60fffa3fe751db82680229e8
Clear filters https://github.com/python/cpython/pull/155862/files
Please reload this pagehttps://github.com/python/cpython/pull/155862/files
Please reload this pagehttps://github.com/python/cpython/pull/155862/files
enum.py https://github.com/python/cpython/pull/155862/files#diff-e5dd6e444e4e6c2cdeb8edf271d057f9da52f7b406dcd8b655dc396fb013bd03
test_enum.py https://github.com/python/cpython/pull/155862/files#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4c
2026-08-15-18-16-16.gh-issue-121291.WljPkh.rst https://github.com/python/cpython/pull/155862/files#diff-123743cff77ebc11a53f284a5c545afe9f0cc5078f07e64ea53445e04275b767
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L462
Lib/enum.pyhttps://github.com/python/cpython/pull/155862/files#diff-e5dd6e444e4e6c2cdeb8edf271d057f9da52f7b406dcd8b655dc396fb013bd03
View file https://github.com/SomSamantray/cpython/blob/070ec61c706a30ce60fffa3fe751db82680229e8/Lib/enum.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/155862/{{ revealButtonHref }}
https://github.com/python/cpython/pull/155862/files#diff-e5dd6e444e4e6c2cdeb8edf271d057f9da52f7b406dcd8b655dc396fb013bd03
https://github.com/python/cpython/pull/155862/files#diff-e5dd6e444e4e6c2cdeb8edf271d057f9da52f7b406dcd8b655dc396fb013bd03
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L463
Lib/test/test_enum.pyhttps://github.com/python/cpython/pull/155862/files#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4c
View file https://github.com/SomSamantray/cpython/blob/070ec61c706a30ce60fffa3fe751db82680229e8/Lib/test/test_enum.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/155862/{{ revealButtonHref }}
https://github.com/python/cpython/pull/155862/files#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4c
https://github.com/python/cpython/pull/155862/files#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4c
https://github.com/python/cpython/pull/155862/files#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4c
https://github.com/python/cpython/pull/155862/files#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4c
Misc/NEWS.d/next/Library/2026-08-15-18-16-16.gh-issue-121291.WljPkh.rsthttps://github.com/python/cpython/pull/155862/files#diff-123743cff77ebc11a53f284a5c545afe9f0cc5078f07e64ea53445e04275b767
View file https://github.com/SomSamantray/cpython/blob/070ec61c706a30ce60fffa3fe751db82680229e8/Misc/NEWS.d/next/Library/2026-08-15-18-16-16.gh-issue-121291.WljPkh.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/155862/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/155862/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.