From b0b836b20cb56c225874a4a39ef895f89ab2970f Mon Sep 17 00:00:00 2001 From: John Belmonte Date: Mon, 11 Apr 2022 23:34:18 +0900 Subject: 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 --- Python/ast_opt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'Python/ast_opt.c') diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 77ed29d0cdd..b1d807bcf10 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -310,6 +310,7 @@ simple_format_arg_parse(PyObject *fmt, Py_ssize_t *ppos, case ' ': *flags |= F_BLANK; continue; case '#': *flags |= F_ALT; continue; case '0': *flags |= F_ZERO; continue; + case 'z': *flags |= F_NO_NEG_0; continue; } break; } -- cgit v1.2.3