]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] [Enum] fix check in _test_simple_enum (GH-96435)
authorEthan Furman <ethan@stoneleaf.us>
Tue, 30 Aug 2022 19:39:03 +0000 (12:39 -0700)
committerGitHub <noreply@github.com>
Tue, 30 Aug 2022 19:39:03 +0000 (12:39 -0700)
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>
Lib/enum.py
Lib/test/test_enum.py

index 63ca1605353a7d98e1e13f4843ebe9447bcd513e..28b638c28f17763ccba3319e3407f5890ad69c18 100644 (file)
@@ -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
index 4a42c738172100a6c00005eac7fbd5d03067f5b9..7964d3e474cd27ae55d028e62c6b9e61c9a295f7 100644 (file)
@@ -4337,10 +4337,16 @@ class TestStdLib(unittest.TestCase):
             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(