Skip to content

Conversation

@sobolevn
Copy link
Member

@sobolevnsobolevn commented Jul 17, 2024

(cherry picked from commit 72dccd6)

Since PyComplex_RealAsDouble uses PyFloat_AsDouble, it can still fail there:

double
PyComplex_RealAsDouble(PyObject*op)
{
if (PyComplex_Check(op)){
return ((PyComplexObject*)op)->cval.real;
}
else{
returnPyFloat_AsDouble(op);
}
}

While PyComplex_ImagAsDouble is always successful:

double
PyComplex_ImagAsDouble(PyObject*op)
{
if (PyComplex_Check(op)){
return ((PyComplexObject*)op)->cval.imag;
}
else{
return0.0;
}
}


📚 Documentation preview 📚: https://cpython-previews--121897.org.readthedocs.build/

(cherry picked from commit 72dccd6) Co-authored-by: sobolevn <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
@sobolevn
Copy link
MemberAuthor

cc @skirpichev

Copy link
Member

@skirpichevskirpichev left a comment

Choose a reason for hiding this comment

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

One remark on PyComplex_ImagAsDouble(). The rest LGTM.

Co-authored-by: Sergey B Kirpichev <[email protected]>
@sobolevnsobolevn enabled auto-merge (squash) July 17, 2024 07:26
@sobolevnsobolevn merged commit 6a19d22 into python:3.12Jul 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@sobolevn@skirpichev