| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I decided to use alternative approach, ignoring errno, as proposed in #156145. This is in a separate commit and can be easily reverted. Edit: this will benefit from new private API in #156694. So, I would appreciate if that pr will be reviewed/merged first. |
Sorry, something went wrong.
|
This breaks cmath.polar() for an underflowing atan2(): >>> import cmath
>>> cmath.polar(complex(1e300, 1e-320))
Traceback (most recent call last):
...
OverflowError: math range erroratan2(1e-320, 1e300) underflows and sets errno to ERANGE. Currently _Py_c_abs() resets it to 0, so cmath_polar_impl() does not see it. cmath.phase() fails this way already -- gh-153144. |
Sorry, something went wrong.
|
@serhiy-storchaka, are you suggesting (1) reversion of errno = 0 stuff or (2) you are ok with moving errno = 0 down in cmath_polar_impl()? |
Sorry, something went wrong.
It fixes abs(complex(nan)), when errno was set.
Looks to be a very minor issue. Though, I can revert all C-API changes for a separate PR. |
Sorry, something went wrong.
Oh no, there is no need to revert C API changes in this PR. |
Sorry, something went wrong.
Co-authored-by: Victor Stinner <vstinner@python.org>
There was a problem hiding this comment.
LGTM. Thanks for the updated PR. Errno is now tested by all C _Py_c_abs() tests. There is also a test on Python abs() setting/checking errno. The changes are now well documented in Changelog entries and in the documentation. Good!
Sorry, something went wrong.
|
Merged, thanks for the fix, and sorry for being picky on documenting the change :-D @skirpichev: So what do you think of backporting the fix to Python 3.15 and older without changing _Py_c_abs() API? |
Sorry, something went wrong.
|
For the backport, I suppose that we can do simply what the issue title says: "complex_abs() should call _Py_c_abs() with errno=0 set": just set errno to 0 before calling _Py_c_abs(). |
Sorry, something went wrong.
…55527) abs(complex) no longer raises OverflowError if errno was set to ERANGE by some library call but abs() doesn't overflow. (cherry picked from commit e5d4fa2) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: hpkfft.com <paul@hpkfft.com>
|
GH-157341 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
Should I create backports for <3.15 by hand? |
Sorry, something went wrong.
abs(complex) no longer raises OverflowError if errno was set to ERANGE by some library call but abs() doesn't overflow. _Py_c_abs() no longer sets errno to zero on success, but rather leaves it unchanged. Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: hpkfft.com <paul@hpkfft.com>
|
Thanks for the backport to 3.15. Once it will be merged (after Python 3.15.0 final release), automated backported to 3.13 and 3.14 will be created. No need to backport again by hand. |
Sorry, something went wrong.
abs(complex) no longer raises OverflowError if errno was set to ERANGE by some library call but abs() doesn't overflow. _Py_c_abs() no longer sets errno to zero on success, but rather leaves it unchanged. Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: hpkfft.com <paul@hpkfft.com>
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.