Title: enum.CONFORM behavior breaks backwards compatibility · Issue #103365 · python/cpython · GitHub
Open Graph Title: enum.CONFORM behavior breaks backwards compatibility · Issue #103365 · python/cpython
X Title: enum.CONFORM behavior breaks backwards compatibility · Issue #103365 · python/cpython
Description: Encountered yet another breaking change for enums. There are two problems here: CONFORM doesn't "conform" to members that are partially unsupported CONFORM does not match the previous behavior for Flag. It used to be more similar to STRI...
Open Graph Description: Encountered yet another breaking change for enums. There are two problems here: CONFORM doesn't "conform" to members that are partially unsupported CONFORM does not match the previous behavior for ...
X Description: Encountered yet another breaking change for enums. There are two problems here: CONFORM doesn't "conform" to members that are partially unsupported CONFORM does not match the previous...
Opengraph URL: https://github.com/python/cpython/issues/103365
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"enum.CONFORM behavior breaks backwards compatibility","articleBody":"\r\nEncountered yet another breaking change for enums. There are two problems here:\r\n\r\n* CONFORM doesn't \"conform\" to members that are partially unsupported\r\n* CONFORM does not match the previous behavior for Flag. It used to be more similar to STRICT, but STRICT also doesn't allow partially unsupported members, while Flag in 3.10 did.\r\n\r\nExample to reproduce:\r\n\r\n```python\r\nimport enum\r\nclass SkipFlag(enum.Flag):\r\n A = 1\r\n B = 2\r\n C = 4 | B\r\n\r\nprint(SkipFlag.C in (SkipFlag.A|SkipFlag.C))\r\n\r\nclass SkipIntFlag(enum.IntFlag):\r\n A = 1\r\n B = 2\r\n C = 4 | B\r\n\r\nprint(SkipIntFlag.C in (SkipIntFlag.A|SkipIntFlag.C))\r\n\r\nprint(SkipIntFlag(42).value)\r\nprint(SkipFlag(42).value)\r\n```\r\n\r\nIn Python 3.10.6, this code outputs:\r\n\r\n```\r\nTrue\r\nTrue\r\n42\r\nTraceback (most recent call last):\r\n...\r\nValueError: 42 is not a valid SkipFlag\r\n````\r\n\r\nIn Python 3.11.2:\r\n```\r\nFalse\r\nTrue\r\n42\r\n2\r\n```\r\n\r\nHaving such members as C is useful to create a flags that are distinct from B but always implies B.\r\n\r\nIn a previous comment bug report it was stated that the previous behavior of Flag was CONFORM:\r\n\r\n\u003e Actually, won't need a deprecation period, since the proper default for `Flag` is `CONFORM` as that matches previous behavior.\r\n\r\n_Originally posted by @ethanfurman in https://github.com/python/cpython/issues/96865#issuecomment-1251372597_\r\n\r\nClearly this is incorrect. The previous behavior was more similar to STRICT, but there appears to be no precise equivalent in Python 3.11 to the old behavior. Using STRICT in Python 3.11, `SkipFlag.A | SkipFlag.C` would fail to be created completely.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103494\n* gh-103513\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/benburrill","@type":"Person","name":"benburrill"},"datePublished":"2023-04-08T05:26:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/103365/cpython/issues/103365"}
| 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:6a256e2f-e7c5-6a69-5112-cecc8e9d6d57 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A692:B6892:68FE11:8C9031:6969DA02 |
| html-safe-nonce | 833b155f3bef2a0fc2cb4731ae6343c20a08511f2364058c56a93aef31a9d961 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjkyOkI2ODkyOjY4RkUxMTo4QzkwMzE6Njk2OURBMDIiLCJ2aXNpdG9yX2lkIjoiMzU4MzM1MzE1ODgzOTY4NzY4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a963a3852e672bb524fb2fffb9fcbf71b4f19eece35c00e734465ee0ea1a178b |
| hovercard-subject-tag | issue:1659399948 |
| 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/103365/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e979b963aa10c222d9d4e27ca7f80fe091219a2ba6fdc68d05ce48933ef16b6f/python/cpython/issues/103365 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e979b963aa10c222d9d4e27ca7f80fe091219a2ba6fdc68d05ce48933ef16b6f/python/cpython/issues/103365 |
| og:image:alt | Encountered yet another breaking change for enums. There are two problems here: CONFORM doesn't "conform" to members that are partially unsupported CONFORM does not match the previous behavior for ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | benburrill |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width