Skip to content

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

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

Eclips4
Copy link
Member

@Eclips4 Eclips4 commented Mar 4, 2024

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

Copy link
Member

@JelleZijlstra JelleZijlstra left a 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

@JelleZijlstra JelleZijlstra added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Mar 4, 2024
@Eclips4
Copy link
Member Author

Eclips4 commented Mar 4, 2024

Jelle, there's no need in backports :)
#112145 (which introduce the problem) wasn't backported to 3.12 and 3.11 branches.

@Eclips4 Eclips4 removed needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Mar 4, 2024
@JelleZijlstra
Copy link
Member

Thanks, didn't realize this code changed recently.

@serhiy-storchaka serhiy-storchaka merged commit 8a84eb7 into python:main Mar 4, 2024
@Eclips4 Eclips4 deleted the issue-116316 branch March 4, 2024 18:03
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants