gh-114563: C decimal falls back to pydecimal for unsupported format strings#114879
gh-114563: C decimal falls back to pydecimal for unsupported format strings#114879serhiy-storchaka merged 12 commits intopython:mainfrom
Conversation
…rmat strings
immediate merits:
* eliminate complex workarounds for 'z' format support
(NOTE: mpdecimal recently added 'z' support, so this becomes
efficient in the long term.)
* fix 'z' format memory leak
* fix 'z' format applied to 'F'
* fix missing '#' format support
Suggested and prototyped by Stefan Krah.
Fixes pythongh-114563, pythongh-91060
There was a problem hiding this comment.
LGTM, with one suggestion about the exception handling for the __format__ call.
@skrah Thank you for your help with this. If you happen to have the bandwidth and inclination to take a quick glance at this PR, I'd very much appreciate your input.
|
If I checkout d96a8cd and then apply my own patches, I reach the exact same state as in this PR. When comparing the result to I tested my own patches with @serhiy-storchaka's |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM.
Is it okay that the PyDecimal instance can have a different context?
This is an excellent observation! It is the one thing that cannot be caught by Maybe the easiest thing would be to add another private method to |
|
This is a clever use of the LGTM. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Now please add a NEWS entry (it is a user visible change), and it will be done.
Describe what behavior was changed, not implementation details.
Misc/NEWS.d/next/Library/2024-02-11-20-23-36.gh-issue-114563.RzxNYT.rst
Outdated
Show resolved
Hide resolved
|
Thanks @belm0 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
|
Thanks @belm0 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Sorry, @belm0 and @serhiy-storchaka, I could not cleanly backport this to |
|
Sorry, @belm0 and @serhiy-storchaka, I could not cleanly backport this to |
|
@belm0, do you mind to create a backport for 3.12? It will be easier to backport then from 3.12 to 3.11 than directly to 3.11. |
|
GH-115353 is a backport of this pull request to the 3.12 branch. |
…ormat strings (GH-114879) (GH-115353) Immediate merits: * eliminate complex workarounds for 'z' format support (NOTE: mpdecimal recently added 'z' support, so this becomes efficient in the long term.) * fix 'z' format memory leak * fix 'z' format applied to 'F' * fix missing '#' format support Suggested and prototyped by Stefan Krah. Fixes gh-114563, gh-91060 (cherry picked from commit 72340d1) Co-authored-by: John Belmonte <john@neggie.net> Co-authored-by: Stefan Krah <skrah@bytereef.org>
…unsupported format strings (pythonGH-114879) (pythonGH-115353) Immediate merits: * eliminate complex workarounds for 'z' format support (NOTE: mpdecimal recently added 'z' support, so this becomes efficient in the long term.) * fix 'z' format memory leak * fix 'z' format applied to 'F' * fix missing 'GH-' format support Suggested and prototyped by Stefan Krah. Fixes pythongh-114563, pythongh-91060 (cherry picked from commit 72340d1) (cherry picked from commit 09c98e4) Co-authored-by: John Belmonte <john@neggie.net> Co-authored-by: Stefan Krah <skrah@bytereef.org>
|
GH-115384 is a backport of this pull request to the 3.11 branch. |
…ormat strings (GH-114879) (GH-115384) Immediate merits: * eliminate complex workarounds for 'z' format support (NOTE: mpdecimal recently added 'z' support, so this becomes efficient in the long term.) * fix 'z' format memory leak * fix 'z' format applied to 'F' * fix missing 'GH-' format support Suggested and prototyped by Stefan Krah. Fixes gh-114563, gh-91060 (cherry picked from commit 72340d1) (cherry picked from commit 09c98e4) Co-authored-by: Stefan Krah <skrah@bytereef.org>
…rmat strings (pythonGH-114879) Immediate merits: * eliminate complex workarounds for 'z' format support (NOTE: mpdecimal recently added 'z' support, so this becomes efficient in the long term.) * fix 'z' format memory leak * fix 'z' format applied to 'F' * fix missing '#' format support Suggested and prototyped by Stefan Krah. Fixes pythongh-114563, pythongh-91060 Co-authored-by: Stefan Krah <skrah@bytereef.org>
When the mpdecimal lib fails to parse a format string, we fall back to the pydecimal format implementation.
Notably this allows complex workarounds for 'z' format support to be removed. (mpdecimal added 'z' support in version 4.0.0, so this becomes efficient in the long term.)
Suggested and prototyped by Stefan Krah.
Fixes gh-114563, gh-91060