Uh oh!
There was an error while loading. Please reload this page.
bpo-46301: cover uncomparable values in Enum._convert_ - #30472
Conversation
| [], msg='Names other than CONVERT_TEST_* found.') | ||
| def test_convert_uncomparable(self): | ||
| uncomp = enum.Enum._convert_( |
There was a problem hiding this comment.
Moreover, _convert_ was not tested on plain Enum
There was a problem hiding this comment.
_convert_ was not intended to be called on plain Enum -- it's purpose it to convert existing constants in a module to enums, and existing constants will already be str or int (or possibly something else, like complex).
There was a problem hiding this comment.
Change the UNCOMPARABLE_* values as suggested above, and also add a test using a complex type.
sobolevn
commented
Jan 7, 2022
@AlexWaygood can you please add "skip news" to this PR? I can't add labels myself 🙂 |
| CONVERT_STRING_TEST_NAME_E = 5 | ||
| CONVERT_STRING_TEST_NAME_F = 5 | ||
| # We also need values that cannot be compared: |
There was a problem hiding this comment.
All we need for this test is for UNCOMPARABLE_* to be different types of values:
UNCOMPABLE_A = 5UNCOMPABLE_C = (9, 4)UNCOMPABLE_B = 'hello'
| [], msg='Names other than CONVERT_TEST_* found.') | ||
| def test_convert_uncomparable(self): | ||
| uncomp = enum.Enum._convert_( |
There was a problem hiding this comment.
Change the UNCOMPARABLE_* values as suggested above, and also add a test using a complex type.
bedevere-bot
commented
Jan 7, 2022
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
sobolevn
commented
Jan 8, 2022
Thanks! I've added one more case with I have made the requested changes; please review again |
bedevere-bot
commented
Jan 8, 2022
Thanks for making the requested changes! @ethanfurman: please review the changes made to this pull request. |
Thank you! 👍 |
pablogsal
commented
Jan 9, 2022
Seems that this PR has broken the refleak buildbots: https://buildbot.python.org/all/#/builders/320/builds/269/ According to our buildbot policy, if this is not fixed in 24h we will need to revert |
@pablogsal thanks for the info! I would love to help to get this fixed, but I am not familiar with how refleak works. And since this is a test-only PR I am bit surprised that this happened 🤔 From https://buildbot.python.org/all/#/builders/384/builds/255 🤔 |
sobolevn
commented
Jan 9, 2022
I was able to reproduce this locally on macos with |
sobolevn
commented
Jan 9, 2022
|
pablogsal
commented
Jan 9, 2022
I am not at my computer so I cannot test, but the problem that happens in these cases where only tests are added is that the new tests are either modifying the global state or adding some sort of cache. |
Ok, looks like I've found the problem: Line 833 in 1bee9a4 When I comment this line out - tests pass, with it - we have a refleak. |
pablogsal
commented
Jan 9, 2022
Yeah, this is an example of "modifying the global state". Tests should be idempotent, and they should leave everything as it was before |
sobolevn
commented
Jan 9, 2022
Yes, you are right! These tests do modify the global state. They add a new class to the current module.
But this line is from Either way, I will open a new PR with |
ethanfurman
commented
Jan 10, 2022
The line The clue was good, though -- the global constants that are converted into enums need to be reset to their original values, either before or after the test runs. |
@sobolevn add to the top of to the bottom. Make similar changes to |
sobolevn
commented
Jan 10, 2022
Oh, sorry, I've missed your comment in the morning 🙂 |
https://bugs.python.org/issue46301