[Python-checkins] [3.11] [Enum] fix check in _test_simple_enum (GH-96435)

ethanfurman webhook-mailer at python.org
Tue Aug 30 15:39:31 EDT 2022


https://github.com/python/cpython/commit/8f58db2279a97d826e5bfa99627ba9bb66f6f096
commit: 8f58db2279a97d826e5bfa99627ba9bb66f6f096
branch: 3.11
author: Ethan Furman <ethan at stoneleaf.us>
committer: ethanfurman <ethan at stoneleaf.us>
date: 2022-08-30T12:39:03-07:00
summary:

[3.11] [Enum] fix check in _test_simple_enum (GH-96435)

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 at users.noreply.github.com>

files:
M Lib/enum.py
M Lib/test/test_enum.py

diff --git a/Lib/enum.py b/Lib/enum.py
index 63ca1605353..28b638c28f1 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -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
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 4a42c738172..7964d3e474c 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -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(



More information about the Python-checkins mailing list