https://github.com/python/cpython/commit/48e52fe2c9a7b33671f6b5d1420a71a6f31ad64b
commit: 48e52fe2c9a7b33671f6b5d1420a71a6f31ad64b
branch: main
author: Momo Eissenhauer <[email protected]>
committer: encukou <[email protected]>
date: 2024-05-07T13:42:18+02:00
summary:
gh-118310: Fix documentation for `enum.Enum.__new__` (GH-118311)
The provided example was incorrect:
- The example enum was missing the `int` mixin as implied by the context
- The value of `int('1a', 16)` was incorrectly given as 17
(should be 26)
files:
M Doc/library/enum.rst
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index 00f617e5ffc5e7..6837b45894b3a9 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -402,13 +402,15 @@ Data Types
in the member assignment will be passed; e.g.
>>> from enum import Enum
- >>> class MyIntEnum(Enum):
- ... SEVENTEEN = '1a', 16
+ >>> class MyIntEnum(int, Enum):
+ ... TWENTYSIX = '1a', 16
- results in the call ``int('1a', 16)`` and a value of ``17`` for the
member.
+ results in the call ``int('1a', 16)`` and a value of ``26`` for the
member.
- .. note:: When writing a custom ``__new__``, do not use
``super().__new__`` --
- call the appropriate ``__new__`` instead.
+ .. note::
+
+ When writing a custom ``__new__``, do not use ``super().__new__`` --
+ call the appropriate ``__new__`` instead.
.. method:: Enum.__repr__(self)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]