Skip to content

Commit

Permalink
[3.11] [Enum] fix check in _test_simple_enum (GH-96435)
Browse files Browse the repository at this point in the history
The builtin `property` is not a callable, so was failing the check in
`_test_simple_enum` causing a match failure; this adds `property` to the
bypass list.

Co-authored-by: Alexandru Mărășteanu <alexei@users.noreply.github.com>
  • Loading branch information
ethanfurman and alexei committed Aug 30, 2022
1 parent d00a9e0 commit 8f58db2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ def _test_simple_enum(checked_enum, simple_enum):
else:
checked_value = checked_dict[key]
simple_value = simple_dict[key]
if callable(checked_value):
if callable(checked_value) or isinstance(checked_value, bltns.property):
continue
if key == '__doc__':
# remove all spaces/tabs
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4337,10 +4337,16 @@ class SimpleColor:
CYAN = 1
MAGENTA = 2
YELLOW = 3
@bltns.property
def zeroth(self):
return 'zeroed %s' % self.name
class CheckedColor(Enum):
CYAN = 1
MAGENTA = 2
YELLOW = 3
@bltns.property
def zeroth(self):
return 'zeroed %s' % self.name
self.assertTrue(_test_simple_enum(CheckedColor, SimpleColor) is None)
SimpleColor.MAGENTA._value_ = 9
self.assertRaisesRegex(
Expand Down

0 comments on commit 8f58db2

Please sign in to comment.