FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

complex_abs() should call _Py_c_abs() with errno=0 set · Issue #155526 · python/cpython · GitHub

Repository navigation

complex_abs() should call _Py_c_abs() with errno=0 set #155526

Closed

Description

Bug report

Bug description:

Other _Py_* helpers in the complexobject.c - only set errno on errors, assuming that it was set to 0 prior to the function call. This is not the case for _Py_c_abs().

So, it's possible to trigger OverflowError in abs() for nan's input:

$ cat a.py
import _testcapi
z = complex('nan')
_testcapi.set_errno(34)
abs(z)
$ ./python a.py 
Traceback (most recent call last):
  File "/home/sk/src/cpython/a.py", line 4, in <module>
    abs(z)
    ~~~^^^
OverflowError: absolute value too large

Credits for @devdanzin for discovery.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. self-assigned this
    on Aug 11, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Aug 11, 2026
  3. removed their assignment
    on Aug 11, 2026
  4. added a commit that references this issue on Sep 11, 2026
  5. added a commit that references this issue on Sep 11, 2026
  6. added a commit that references this issue on Sep 12, 2026
  7. added a commit that references this issue on Sep 14, 2026
  8. added a commit that references this issue on Sep 15, 2026
  9. added a commit that references this issue on Sep 15, 2026
  10. added a commit that references this issue on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL