]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93035: [Enum] Fix IntFlag crash when no single-bit members (GH-93076)
authorTobin Yehle <tobinyehle@gmail.com>
Wed, 25 May 2022 01:16:20 +0000 (19:16 -0600)
committerGitHub <noreply@github.com>
Wed, 25 May 2022 01:16:20 +0000 (18:16 -0700)
`EnumType` attempts to create a custom docstring for each enum/flag, but that was failing with pathological flags that had no members (only multi-bit aliases).

Lib/enum.py

index 64b44197df522df9ce11250e8b1f7872b4fb30e2..0b97d3d8a68ef092c74c1d2f5559a150aa8ff469 100644 (file)
@@ -538,7 +538,7 @@ class EnumType(type):
         #
         # create a default docstring if one has not been provided
         if enum_class.__doc__ is None:
-            if not member_names:
+            if not member_names or not list(enum_class):
                 enum_class.__doc__ = classdict['__doc__'] = _dedent("""\
                         Create a collection of name/value pairs.