FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-116600: [Enum] fix global Flag repr by ethanfurman · Pull Request #116615 · python/cpython · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Lib/enum.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :func:`repr` for global :class:`~enum.Flag` members.

Back | FazBrowse Home | New Git URL