Title: Iterating over `enum.Flag` types ignores zero-valued in Python 3.11 · Issue #109633 · python/cpython · GitHub
Open Graph Title: Iterating over `enum.Flag` types ignores zero-valued in Python 3.11 · Issue #109633 · python/cpython
X Title: Iterating over `enum.Flag` types ignores zero-valued in Python 3.11 · Issue #109633 · python/cpython
Description: Bug report Bug description: In Python 3.10, you can iterate over enum.Enum and enum.Flag types to yield their values. >>> import sys; print(sys.version) 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0] >>> i...
Open Graph Description: Bug report Bug description: In Python 3.10, you can iterate over enum.Enum and enum.Flag types to yield their values. >>> import sys; print(sys.version) 3.10.12 | packaged by conda-forge | (main, J...
X Description: Bug report Bug description: In Python 3.10, you can iterate over enum.Enum and enum.Flag types to yield their values. >>> import sys; print(sys.version) 3.10.12 | packaged by conda-forge |...
Opengraph URL: https://github.com/python/cpython/issues/109633
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Iterating over `enum.Flag` types ignores zero-valued in Python 3.11","articleBody":"# Bug report\n\n### Bug description:\n\nIn Python 3.10, you can iterate over `enum.Enum` and `enum.Flag` types to yield their values.\n\n```python\n\u003e\u003e\u003e import sys; print(sys.version)\n3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]\n\n\u003e\u003e\u003e import enum\n\u003e\u003e\u003e class MyEnum(enum.Enum):\n... A = 0\n... B = 1\n... C = 2\n...\n\u003e\u003e\u003e list(MyEnum)\n[\u003cMyEnum.A: 0\u003e, \u003cMyEnum.B: 1\u003e, \u003cMyEnum.C: 2\u003e]\n\n\u003e\u003e\u003e class MyFlag(enum.Flag):\n... A = 0\n... B = 1\n... C = 2\n...\n\u003e\u003e\u003e list(MyFlag)\n[\u003cMyFlag.A: 0\u003e, \u003cMyFlag.B: 1\u003e, \u003cMyFlag.C: 2\u003e]\n```\n\nIn Python 3.11, the same is true for `enum.Enum` types, but the behavior seems to have changed for `enum.Flag` types. Now, iterating over the type only yields its nonzero values.\n\n```python\n\u003e\u003e\u003e import sys; print(sys.version)\n3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]\n\n\u003e\u003e\u003e import enum\n\u003e\u003e\u003e class MyEnum(enum.Enum):\n... A = 0\n... B = 1\n... C = 2\n...\n\u003e\u003e\u003e list(MyEnum)\n[\u003cMyEnum.A: 0\u003e, \u003cMyEnum.B: 1\u003e, \u003cMyEnum.C: 2\u003e]\n\n\u003e\u003e\u003e class MyFlag(enum.Flag):\n... A = 0\n... B = 1\n... C = 2\n...\n\u003e\u003e\u003e list(MyFlag)\n[\u003cMyFlag.B: 1\u003e, \u003cMyFlag.C: 2\u003e] # Missing \u003cMyFlag.A: 0\u003e (!)\n```\n\n\n### CPython versions tested on:\n\n3.10, 3.11\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/gmgunter","@type":"Person","name":"gmgunter"},"datePublished":"2023-09-21T01:16:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/109633/cpython/issues/109633"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bddce549-ecb9-b822-8316-ac52d76975ab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE3C:3A06E8:7686C4:A7BA8B:6A51030F |
| html-safe-nonce | 49e54ce7128f8cbf551111351fca905b44db37fb6ec0e662374450623ddecf91 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTNDOjNBMDZFODo3Njg2QzQ6QTdCQThCOjZBNTEwMzBGIiwidmlzaXRvcl9pZCI6IjgwNTI0MTg3NDUxOTk1NTk0MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3defbf13f9e6d29cf521d977638b291bd8cd4923793c4c13c14291ba7434c87d |
| hovercard-subject-tag | issue:1905917778 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/109633/issue_layout |
| twitter:image | https://opengraph.githubassets.com/11d0a5e6f8e22021c1921dd73fcef483186e6be7c983604a38b4bdae482ba974/python/cpython/issues/109633 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/11d0a5e6f8e22021c1921dd73fcef483186e6be7c983604a38b4bdae482ba974/python/cpython/issues/109633 |
| og:image:alt | Bug report Bug description: In Python 3.10, you can iterate over enum.Enum and enum.Flag types to yield their values. >>> import sys; print(sys.version) 3.10.12 | packaged by conda-forge | (main, J... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gmgunter |
| hostname | github.com |
| expected-hostname | github.com |
| None | 38906a4da4e3e9fd88dfeacee232f5932c0c5f7495de3b4efc53ddfac7173d12 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 90441ea9b98e7491aa6ebcd135fccce4e2396f48 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width