-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
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. Fixes pythongh-114563, pythongh-91060
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> Co-authored-by: Stefan Krah <[email protected]>
…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 <[email protected]> Co-authored-by: Stefan Krah <[email protected]>
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 <[email protected]>
…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 <[email protected]>
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