Uh oh!
There was an error while loading. Please reload this page.
gh-114563: C decimal falls back to pydecimal for unsupported format strings - #114879
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. Fixespythongh-114563, pythongh-91060
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
skrah
commented
Feb 10, 2024
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>
Uh oh!
There was an error while loading. Please reload this page.
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?
skrah
commented
Feb 10, 2024
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 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
skrah
commented
Feb 11, 2024
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.
Uh oh!
There was an error while loading. Please reload this page.
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 |
serhiy-storchaka
commented
Feb 12, 2024
@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. Fixesgh-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. Fixespythongh-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. Fixesgh-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. Fixespythongh-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.
Fixesgh-114563, gh-91060