[Python-checkins] gh-93035: [Enum] Fix IntFlag crash when no single-bit members (GH-93076)

ethanfurman webhook-mailer at python.org
Tue May 24 21:16:38 EDT 2022


https://github.com/python/cpython/commit/08cfc3dabf0f81a4494cd0d697befc7d0dec77b7
commit: 08cfc3dabf0f81a4494cd0d697befc7d0dec77b7
branch: main
author: Tobin Yehle <tobinyehle at gmail.com>
committer: ethanfurman <ethan at stoneleaf.us>
date: 2022-05-24T18:16:20-07:00
summary:

gh-93035: [Enum] Fix IntFlag crash when no single-bit members (GH-93076)

`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).

files:
M Lib/enum.py

diff --git a/Lib/enum.py b/Lib/enum.py
index 64b44197df522..0b97d3d8a68ef 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -538,7 +538,7 @@ def __new__(metacls, cls, bases, classdict, *, boundary=None, _simple=False, **k
         #
         # 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.
 



More information about the Python-checkins mailing list