-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-116316: Fix typo in UNARY_FUNC(PyNumber_Positive)
macros
#116317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Seems like this only affects the error message that gets thrown if a __pos__
method returns NULL without an exception or non-NULL with an exception, which can only happen with a poorly written C extension that overrides this slot. You can see it with this patch:
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index d8b0e84da5..b374c564af 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -577,6 +577,7 @@ complex_neg(PyComplexObject *v)
static PyObject *
complex_pos(PyComplexObject *v)
{
+ return NULL;
if (PyComplex_CheckExact(v)) {
return Py_NewRef(v);
}
Python 3.13.0a4+ (heads/pep696v2-dirty:a265008fa5, Mar 4 2024, 09:31:12) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> +1j
Fatal Python error: _Py_CheckSlotResult: Slot __pow__ of type complex failed without setting an exception
Python runtime state: initialized
Current thread 0x00000001f12f9e00 (most recent call first):
<no Python frame>
zsh: abort ./python.exe
Jelle, there's no need in backports :) |
Thanks, didn't realize this code changed recently. |
UNARY_FUNC(PyNumber_Positive)
#116316