summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-08-31 22:04:55 (GMT)
committerGitHub <noreply@github.com>2023-08-31 22:04:55 (GMT)
commit8c3793a539ce950e552da390b7b24485dd655237 (patch)
treef270c1cc50d17f694166ac1b6af27c2c3006091d /Misc
parenta92c60c99bab716d1d08bccb92dcc0fe6ee93abe (diff)
downloadcpython-8c3793a539ce950e552da390b7b24485dd655237.zip
cpython-8c3793a539ce950e552da390b7b24485dd655237.tar.gz
cpython-8c3793a539ce950e552da390b7b24485dd655237.tar.bz2
[3.12] gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704) (#108733)
gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704) When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. . member = object.__new__(cls) member = int.__new__(cls, value) member = str.__new__(cls, value) Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected. (cherry picked from commit d48760b2f1e28dd3c1a35721939f400a8ab619b8) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2023-08-30-20-10-28.gh-issue-108682.c2gzLQ.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2023-08-30-20-10-28.gh-issue-108682.c2gzLQ.rst b/Misc/NEWS.d/next/Library/2023-08-30-20-10-28.gh-issue-108682.c2gzLQ.rst
new file mode 100644
index 0000000..148d432
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-08-30-20-10-28.gh-issue-108682.c2gzLQ.rst
@@ -0,0 +1,2 @@
+Enum: raise :exc:`TypeError` if ``super().__new__()`` is called from a
+custom ``__new__``.