gh-145633: deprecate float.__getformat__() class method#146400
gh-145633: deprecate float.__getformat__() class method#146400skirpichev wants to merge 4 commits intopython:mainfrom
Conversation
| or not math.issubnormal(math.nextafter(0, 1))): | ||
| return False | ||
| try: | ||
| import ctypes |
There was a problem hiding this comment.
You should move this check before the big if above, no?
There was a problem hiding this comment.
We still need at least some checks on implementations without the ctypes module. It seems, the struct module is available on WASI, I'll use it here.
That's why I think that the second option --- i.e. use iec_559 flag for format-only --- maybe is better.
There was a problem hiding this comment.
Your current code starts with ctypes.sizeof(ctypes.c_double) != 8, but it only imports ctypes a few lines below. It cannot work.
There was a problem hiding this comment.
I've fixed that. Though, maybe it's better just to drop the size check.
| (Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.) | ||
|
|
||
| * The ``__getformat__()`` class method of the :class:`float` is deprecated | ||
| and will be removed in Python 3.20. |
There was a problem hiding this comment.
You should document the deprecation in What's New in Python 3.15.
What is the migration path for projects currently relying on __getformat__()? Do they have to copy/paste the big _have_ieee_doubles() function?
There was a problem hiding this comment.
What is the migration path for projects currently relying on getformat()? Do they have to copy/paste the big _have_ieee_doubles() function?
Primary goal is using the CPython's test suite. No changes needed.
But for the rest - yes.
📚 Documentation preview 📚: https://cpython-previews--146400.org.readthedocs.build/