Skip to content

gh-133895: provide C99 Annex G return values for cmath's functions #134995

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Jun 1, 2025

Now this information is available as the "value" attribute of raised exception objects, for example:

>>> import cmath
>>> try:
...     cmath.log(complex(-0.0, 0))
... except ValueError as exc:
...     print(exc.value)
...
(-inf+3.141592653589793j)

Also uses the AC magic for return value of the cmath.rect().


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

Now this information is available as the "value" attribute
of the ValueError exception object:

```pycon
>>> import cmath
>>> try:
...     cmath.log(complex(-0.0, 0))
... except ValueError as exc:
...     print(exc.value)
...
(-inf+3.141592653589793j)
```

Also uses the AC magic for return value of the cmath.rect().
@skirpichev
Copy link
Contributor Author

CC @abhigyan631 as author of #133923

@skirpichev skirpichev changed the title gh-133895: provide C99 Annex G return values for cmath functions gh-133895: provide C99 Annex G return values for cmath's functions Jun 1, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@skirpichev skirpichev marked this pull request as draft June 2, 2025 09:06
@skirpichev skirpichev marked this pull request as ready for review June 5, 2025 04:40
@skirpichev
Copy link
Contributor Author

skirpichev commented Jun 5, 2025

I changed exception handling along the way, suggested by @serhiy-storchaka. I hope I did that right. If so, I can adjust the math's pr.

Now we add value to OverflowError's too. This reveals two bugs (in sinh and cosh), fixed.

@skirpichev skirpichev requested a review from picnixz June 5, 2025 05:06
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