mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)
Add "z" format specifier to coerce negative 0 to zero. See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995) for discussion. This covers `str.format()` and f-strings. Old-style string interpolation is not supported. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This commit is contained in:
parent
dd207a6ac5
commit
b0b836b20c
16 changed files with 368 additions and 43 deletions
|
@ -14,12 +14,14 @@ extern "C" {
|
|||
* F_BLANK ' '
|
||||
* F_ALT '#'
|
||||
* F_ZERO '0'
|
||||
* F_NO_NEG_0 'z'
|
||||
*/
|
||||
#define F_LJUST (1<<0)
|
||||
#define F_SIGN (1<<1)
|
||||
#define F_BLANK (1<<2)
|
||||
#define F_ALT (1<<3)
|
||||
#define F_ZERO (1<<4)
|
||||
#define F_NO_NEG_0 (1<<5)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr);
|
|||
#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */
|
||||
#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code
|
||||
specific */
|
||||
#define Py_DTSF_NO_NEG_0 0x08 /* negative zero result is coerced to 0 */
|
||||
|
||||
/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */
|
||||
#define Py_DTST_FINITE 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue