gh-114563: C decimal falls back to pydecimal for unsupported format s… · python/cpython@72340d1 · GitHub
Skip to content

Commit 72340d1

Browse files
belm0Stefan Krah
andauthored
gh-114563: C decimal falls back to pydecimal for unsupported format strings (GH-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 gh-114563, gh-91060 Co-authored-by: Stefan Krah <skrah@bytereef.org>
1 parent 235cacf commit 72340d1

3 files changed

Lines changed: 88 additions & 122 deletions

File tree

Lib/test/test_decimal.py

Lines changed: 22 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix several :func:`format()` bugs when using the C implementation of :class:`~decimal.Decimal`:
2+
* memory leak in some rare cases when using the ``z`` format option (coerce negative 0)
3+
* incorrect output when applying the ``z`` format option to type ``F`` (fixed-point with capital ``NAN`` / ``INF``)
4+
* incorrect output when applying the ``#`` format option (alternate form)

Modules/_decimal/_decimal.c

Lines changed: 62 additions & 122 deletions

0 commit comments

Comments
 (0)