pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/06e29a224fac9edeba55422d2e60f2fbb88dddce

gh-116600: [Enum] fix global Flag repr (GH-116615) · python/cpython@06e29a2 · GitHub
Skip to content

Commit 06e29a2

Browse files
ethanfurmanEclips4
andauthored
gh-116600: [Enum] fix global Flag repr (GH-116615)
* and fix global flag repr * Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
1 parent 3e45030 commit 06e29a2

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/enum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ def global_flag_repr(self):
16801680
cls_name = self.__class__.__name__
16811681
if self._name_ is None:
16821682
return "%s.%s(%r)" % (module, cls_name, self._value_)
1683-
if _is_single_bit(self):
1683+
if _is_single_bit(self._value_):
16841684
return '%s.%s' % (module, self._name_)
16851685
if self._boundary_ is not FlagBoundary.KEEP:
16861686
return '|'.join(['%s.%s' % (module, name) for name in self.name.split('|')])

Lib/test/test_enum.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,8 @@ def test_global_repr_conform1(self):
40634063

40644064
@reraise_if_not_enum(NoName)
40654065
def test_global_enum_str(self):
4066+
self.assertEqual(repr(NoName.ONE), 'test_enum.ONE')
4067+
self.assertEqual(repr(NoName(0)), 'test_enum.NoName(0)')
40664068
self.assertEqual(str(NoName.ONE & NoName.TWO), 'NoName(0)')
40674069
self.assertEqual(str(NoName(0)), 'NoName(0)')
40684070

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :func:`repr` for global :class:`~enum.Flag` members.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy