[3.12] gh-118310: Fix documentation for enum.Enum.__new__ (GH-118311) (GH-118699)

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)
(cherry picked from commit 48e52fe2c9)

Co-authored-by: Momo Eissenhauer <mmEissen@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-05-07 14:02:55 +02:00 committed by GitHub
parent f85021a6a2
commit 8e53f66797
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -392,13 +392,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)