# Bug report

### Bug description:

Right now we do this after invocation of the function or it's optimized alternative (for small integers).  That has advantage as - IIUC - both algorithms may trigger error condition.  On another hand, behaviour of the public C API function ``_Py_c_pow()`` (used in the CPython codebase only for ``complex_pow()``) will differ from the pure-python pow()...

Other similar functions (``complex_div()`` and ``complex_abs()``) leave setting ``errno`` to corresponding C-API function.

My proposal: move ``_Py_ADJUST_ERANGE2()`` call to ``_Py_c_pow()`` and ``c_powi()``.  If that does make sense I'll provide a patch.

### CPython versions tested on:

CPython main branch

### Operating systems tested on:

_No response_

<!-- gh-linked-prs -->
### Linked PRs
* gh-120256
<!-- /gh-linked-prs -->

_Py_c_pow() should adjust errno on error conditions
This is a GitHub Issue
repo:cpython
owner:python
Title : _Py_c_pow() should adjust errno on error conditions
Issue date:

--- start body ---
# Bug report

### Bug description:

Right now we do this after invocation of the function or it's optimized alternative (for small integers).  That has advantage as - IIUC - both algorithms may trigger error condition.  On another hand, behaviour of the public C API function ``_Py_c_pow()`` (used in the CPython codebase only for ``complex_pow()``) will differ from the pure-python pow()...

Other similar functions (``complex_div()`` and ``complex_abs()``) leave setting ``errno`` to corresponding C-API function.

My proposal: move ``_Py_ADJUST_ERANGE2()`` call to ``_Py_c_pow()`` and ``c_powi()``.  If that does make sense I'll provide a patch.

### CPython versions tested on:

CPython main branch

### Operating systems tested on:

_No response_

<!-- gh-linked-prs -->
### Linked PRs
* gh-120256
<!-- /gh-linked-prs -->

--- end body ---
