[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Miro Hrončok
New submission from Miro Hrončok : With the change introduced in https://bugs.python.org/issue38250 https://github.com/python/cpython/commit/7aaeb2a3d682ecba125c33511e4b4796021d2f82 I observe a regression in behavior of enum.IntFlag with missing values. Consider this code (from pyproj): f

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ned Deily
Change by Ned Deily : -- nosy: +pablogsal ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: We are already blocked in Python 3.10 beta 2, Ethan, could you give a look at this so we can introduce the fix when we release the next beta? -- ___ Python tracker _

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: That is an intentional change. The cause is that the masks include bits that are not named in the Flag. The user-side fix is to add a `boundary=KEEP` option to the flag: class GeodIntermediateFlag(IntFlag, boundary=KEEP) The enum library fix could be one

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread John Belmonte
John Belmonte added the comment: To clarify, it's caused by these mask entries in the enum: NPTS_MASK = 0xF DEL_S_MASK = 0xF0 AZIS_MASK = 0xF00 Since the masks are not an aggregation of individual bits defined in the enum, it's an error. > I'm inclined to go with [removing the check], since

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread John Belmonte
John Belmonte added the comment: I wonder if CONFORM could tolerate these, since it's ultimately going to discard invalid bits. And then perhaps CONFORM is the default. -- ___ Python tracker __

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: Actually, thinking about that a little bit more, KEEP was added for exactly this situation, as some stdlib flags exhibit the same behavior. So the real question is what should happen with, for example, GeodIntermediateFlag(0x80) ? The idea behind boundary

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: Those are good points -- the difficulty is knowing which behavior the user wants. And if the desired run-time behavior doesn't match the boundary flag the user is stuck. -- ___ Python tracker

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: For example, if the default is CONFORM or KEEP, but the user wants an error if 0x80 comes up, they would have to explicitly check for that value since the Flag would happily return it instead of raising. -- ___ Pyth

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread John Belmonte
John Belmonte added the comment: Rather than make such masks containing unknown bits, this would be best practice if you want to use STRICT, correct? NPTS_ROUND = 0x0 NPTS_CEIL = 0x1 NPTS_TRUNC = 0x2 NPTS_MASK = NPTS_ROUND | NPTS_CEIL | NPTS_TRUNC Otherwise, if your input may have unknown bi

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: Yes, that would be best practice. However, if the user is interfacing with other software/hardware, they may not have a choice on which bits make up the mask. -- ___ Python tracker

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread John Belmonte
John Belmonte added the comment: > However, if the user is interfacing with other software/hardware, they may > not have a choice on which bits make up the mask. I think it's the same as saying "unknown bits may come on the input". An important use case is for forward compatibility, where n

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: That could be, and the user can set the boundary to whatever works best for their use-case, so long as the boundary they want to use does not conflict with the initial creation checks. Do you agree that simply removing the unnamed member check that takes place

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread John Belmonte
John Belmonte added the comment: > Do you agree that simply removing the unnamed member check that takes place > at Flag creation is a good way forward? It's uncomfortable, because then STRICT is not actually strict, and it's going to be show raw values in str/repr. > CONFORM -> unnamed bit

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: I see your point about the str/repr. > But the class members themselves should not have that transform applied, and > raise > an error on invalid bits. But I'm not sure I understand that. Either you are agreeing with me that we should lose the creation time

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread Ethan Furman
Ethan Furman added the comment: I'll be offline for a couple hours, but I'll check back. -- ___ Python tracker ___ ___ Python-bugs-

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-26 Thread John Belmonte
John Belmonte added the comment: > Either [...] we should lose the creation time check (not apply the > transform), or we should still have the check (raise an error on invalid > bits) which would still leave us in this situation. That is only one option (which undesirable consequences are a

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-05-27 Thread Ethan Furman
Ethan Furman added the comment: I'm very much of the practicality beats purity philosophy, so I want to support the OP's flag without making them jump through hoops. On the flip side, I also appreciate that there are folks that want the extra security... So here's my plan: remove the creat

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-04 Thread Thomas Caswell
Thomas Caswell added the comment: This change also affects PyQt6: Python 3.10.0b2+ (heads/3.10:d0991e2db3, Jun 1 2021, 11:42:08) [GCC 11.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import PyQt6.QtCore >>> PyQt6.QtCore.PYQT_VERSION_STR '6.1.1.dev21

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Raising this to a release blocker for 3.10.0 beta 3 as it breaks PyQt6 and other projects. -- priority: normal -> release blocker ___ Python tracker

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-07 Thread Ethan Furman
Change by Ethan Furman : -- keywords: +patch pull_requests: +25170 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26586 ___ Python tracker ___ ___

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-09 Thread Ethan Furman
Ethan Furman added the comment: New changeset eea8148b7dff5ffc7b84433859ac819b1d92a74d by Ethan Furman in branch 'main': bpo-44242: [Enum] remove missing bits test from Flag creation (GH-26586) https://github.com/python/cpython/commit/eea8148b7dff5ffc7b84433859ac819b1d92a74d -- ___

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-09 Thread Ethan Furman
Change by Ethan Furman : -- pull_requests: +25221 pull_request: https://github.com/python/cpython/pull/26635 ___ Python tracker ___

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-10 Thread Ethan Furman
Ethan Furman added the comment: New changeset 749648609de89f14581190ea34b9c0968787a701 by Ethan Furman in branch '3.10': [3.10] bpo-44242: [Enum] remove missing bits test from Flag creation (GH-26586) (GH-26635) https://github.com/python/cpython/commit/749648609de89f14581190ea34b9c0968787a70

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-10 Thread Ethan Furman
Ethan Furman added the comment: Thank you everyone for your help. -- priority: release blocker -> resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.11 ___ Python tracker

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-11 Thread Ethan Furman
Ethan Furman added the comment: Also changing error reporting to be less susceptible to DOS attacks. -- resolution: fixed -> stage: resolved -> status: closed -> open ___ Python tracker ___

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-11 Thread Ethan Furman
Change by Ethan Furman : -- pull_requests: +25256 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26669 ___ Python tracker ___

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-11 Thread Ethan Furman
Ethan Furman added the comment: New changeset c956734d7af83ad31f847d31d0d26df087add9a4 by Ethan Furman in branch 'main': bpo-44242: [Enum] improve error messages (GH-26669) https://github.com/python/cpython/commit/c956734d7af83ad31f847d31d0d26df087add9a4 --

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-11 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 9.0 -> 10.0 pull_requests: +25258 pull_request: https://github.com/python/cpython/pull/26671 ___ Python tracker

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-11 Thread Ethan Furman
Ethan Furman added the comment: New changeset 0a186b1ec1fd094d825f08a4eb39fa83ef57067a by Miss Islington (bot) in branch '3.10': bpo-44242: [Enum] improve error messages (GH-26669) https://github.com/python/cpython/commit/0a186b1ec1fd094d825f08a4eb39fa83ef57067a --

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-14 Thread Jacob Walls
Jacob Walls added the comment: With the followup patch merged, can this be closed now? -- nosy: +jacobtylerwalls ___ Python tracker ___ ___

[issue44242] enum.IntFlag regression: missing values cause TypeError

2021-06-14 Thread Ethan Furman
Ethan Furman added the comment: Yup, just had to get back from the weekend. :-) -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___