Skip to content
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

Python Decimal supports '#' format, C Decimal does not. #91060

Closed
cgevans mannequin opened this issue Mar 2, 2022 · 4 comments
Closed

Python Decimal supports '#' format, C Decimal does not. #91060

cgevans mannequin opened this issue Mar 2, 2022 · 4 comments
Labels
3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@cgevans
Copy link
Mannequin

cgevans mannequin commented Mar 2, 2022

BPO 46904
Nosy @mdickinson, @ericvsmith, @cgevans

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-03-02.23:39:51.993>
labels = ['type-bug', 'library', '3.10', '3.11']
title = "Python Decimal supports '#' format, C Decimal does not."
updated_at = <Date 2022-03-03.00:03:06.014>
user = 'https://github.com/cgevans'

bugs.python.org fields:

activity = <Date 2022-03-03.00:03:06.014>
actor = 'eric.smith'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2022-03-02.23:39:51.993>
creator = 'const'
dependencies = []
files = []
hgrepos = []
issue_num = 46904
keywords = []
message_count = 1.0
messages = ['414390']
nosy_count = 3.0
nosy_names = ['mark.dickinson', 'eric.smith', 'const']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue46904'
versions = ['Python 3.10', 'Python 3.11']

@cgevans
Copy link
Mannequin Author

cgevans mannequin commented Mar 2, 2022

Decimal as implemented in _pydecimal supports the '#' alternate form in format strings, though this does not appear to be documented: as with floats, it causes a decimal point to be included regardless of value. Decimal as implemented in cdecimal, as it uses libmpdec, does not.

This is a rather minor discrepancy; I hadn't actually intended to have # in my format string at all, but it had ended up there and was causing errors for half of the users of my library. # also could be useful for decimals, as it can be for floats.

Like bpo-45739, it's unclear to me whether this is a discrepancy that should be corrected by implementing # for cdecimal, removing # support for _pydecimal, or just documenting the inconsistency.

@cgevans cgevans mannequin added 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 2, 2022
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@mdickinson
Copy link
Member

I agree that the Python and C versions of Decimal should be consistent. The support in the Python version definitely was intentional, and I'd be reluctant to remove it. So options are: (a) do nothing, (b) document the discrepancy, or (c) fix cdecimal.

#58046 is somewhat related.

@skrah
Copy link
Contributor

skrah commented Jan 28, 2024

This is fixed by applying the general format patch in #114563.

serhiy-storchaka pushed a commit that referenced this issue Feb 12, 2024
…trings (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 <[email protected]>
@belm0
Copy link
Contributor

belm0 commented Feb 12, 2024

please close-- fIxed in PR #114879

serhiy-storchaka pushed a commit that referenced this issue Feb 12, 2024
…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]>
belm0 added a commit to belm0/cpython that referenced this issue Feb 13, 2024
…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]>
serhiy-storchaka pushed a commit that referenced this issue Feb 13, 2024
…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]>
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this issue Feb 14, 2024
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants