-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
[C API] Remove Py_OVERFLOWED(), Py_SET_ERRNO_ON_MATH_ERROR(), Py_ADJUST_ERANGE1() #89575
Comments
I propose to remove the following macros from the Python C API:
Only Py_ADJUST_ERANGE1() and Py_ADJUST_ERANGE2() are still used by Python itself, other macros are no longer used since Python 2.7:
I searched for these macros in the PyPI top 5000 modules: none of these macros are used. There is a single match: frozendict-2.0.6 which contains a Include/pyport.h copy, but it doesn't use these macros. -- Py_OVERFLOWED() was used by long_true_divide() and PyLong_AsDouble() in Python 2.6, but Python 2.7 no longer used them. (1) Py_OVERFLOWED() call in long_true_divide() was removed in Python 2.7 by bpo-1811: commit 4657283
(2) Py_OVERFLOWED() call in PyLong_AsDouble() was removed in Python 2.7 by bpo-3166: commit 6736cf8
-- Py_SET_ERRNO_ON_MATH_ERROR() and Py_SET_ERANGE_IF_OVERFLOW() were used in Objects/mathmodule.c in Python 2.5. (1) The last call to Py_SET_ERRNO_ON_MATH_ERROR() was removed by in Python 2.6 by: commit 6f34109
(2) The last call to Py_SET_ERANGE_IF_OVERFLOW() was removed in Python 2.4 by: commit 77d9a3e
|
Py_OVERFLOWED() documentation says that the function is not reliable since C99. Python is using C99 since Python 3.6. /* Py_OVERFLOWED(X)
|
Py_SET_ERRNO_ON_MATH_ERROR() documentation also says that it is not reliable: /* Py_SET_ERRNO_ON_MATH_ERROR(x)
|
Py_ADJUST_ERANGE1() is used by float ** float. Py_ADJUST_ERANGE2() is used by complex ** complex. |
I add Mark Dickinson and Tim Peters who were involved in changes removing usage of these macros. |
And I have doubts about Py_ADJUST_ERANGE2(). I think that it is used incorrectly. See bpo-44970. |
The question here is if it should be exported in the C API. I propose to remove it. Fixing it is a different issue: bpo-44970 :-) |
+1 for the removals. (We should fix bpo-44970 too, but as you say that's a separate issue. And I suspect that the Py_ADJUST_ERANGE1() use for float pow should be replaced, too.) |
Well, it's scary of use functions which are documented as:
|
Oops, Py_OVERFLOWED() has been removed: I created PR 28884 to fix the comment. |
Include/pymath.h is now better, I close the issue ;-) |
See also bpo-46670: "Build Python with -Wundef: don't use undefined macros". |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: