]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-93035: [Enum] Fix IntFlag crash when no single-bit members (GH-93076) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 25 May 2022 17:50:24 +0000 (10:50 -0700)
committerGitHub <noreply@github.com>
Wed, 25 May 2022 17:50:24 +0000 (10:50 -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).
(cherry picked from commit 08cfc3dabf0f81a4494cd0d697befc7d0dec77b7)

Co-authored-by: Tobin Yehle <tobinyehle@gmail.com>
Lib/enum.py

index 31923d757f803ef8ea16baa5b454c92d5c792e66..4a21226f0193f54722ade3f4398b20bb42d60d4a 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.