Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ def global_flag_repr(self):
cls_name = self.__class__.__name__
if self._name_ is None:
return "%s.%s(%r)" % (module, cls_name, self._value_)
if _is_single_bit(self):
if _is_single_bit(self._value_):
return '%s.%s' % (module, self._name_)
if self._boundary_ is not FlagBoundary.KEEP:
return '|'.join(['%s.%s' % (module, name) for name in self.name.split('|')])
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4067,6 +4067,8 @@ def test_global_repr_conform1(self):

@reraise_if_not_enum(NoName)
def test_global_enum_str(self):
self.assertEqual(repr(NoName.ONE), 'test_enum.ONE')
self.assertEqual(repr(NoName(0)), 'test_enum.NoName(0)')
self.assertEqual(str(NoName.ONE & NoName.TWO), 'NoName(0)')
self.assertEqual(str(NoName(0)), 'NoName(0)')

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :func:`repr` for global :class:`~enum.Flag` members.