[Python-checkins] bpo-38659: [Enum] do not check '_inverted_' during simple test (GH-25566)

ethanfurman webhook-mailer at python.org
Fri Apr 23 22:08:41 EDT 2021


https://github.com/python/cpython/commit/6c681e1a4aa2dbca61be9a26c9257d7d25fa29a7
commit: 6c681e1a4aa2dbca61be9a26c9257d7d25fa29a7
branch: master
author: Ethan Furman <ethan at stoneleaf.us>
committer: ethanfurman <ethan at stoneleaf.us>
date: 2021-04-23T19:08:22-07:00
summary:

bpo-38659: [Enum] do not check '_inverted_' during simple test (GH-25566)

Depending on usage, it's possible for Flag members to have the _inverted_ attribute when they are testing, while the Flag being testing against will not have that attribute on its members -- so skip that comparison.

files:
M Lib/enum.py

diff --git a/Lib/enum.py b/Lib/enum.py
index 82be1fbaf70b0..ca6aff6f82512 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -1616,8 +1616,8 @@ def _test_simple_enum(checked_enum, simple_enum):
                 simple_member_dict = simple_enum[name].__dict__
                 simple_member_keys = list(simple_member_dict.keys())
                 for key in set(checked_member_keys + simple_member_keys):
-                    if key in ('__module__', '__objclass__'):
-                        # keys known to be different
+                    if key in ('__module__', '__objclass__', '_inverted_'):
+                        # keys known to be different or absent
                         continue
                     elif key not in simple_member_keys:
                         failed_member.append("missing key %r not in the simple enum member %r" % (key, name))



More information about the Python-checkins mailing list