mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue 2264: empty float presentation type needs to have at least one digit past the decimal point.
Added "Z" format_char to PyOS_ascii_formatd to support empty float presentation type. Renamed buf_size in PyOS_ascii_formatd to more accurately reflect it's meaning. Modified format.__float__ to use the new "Z" format as the default. Added test cases.
This commit is contained in:
parent
43da35de7b
commit
8113ca63b9
3 changed files with 76 additions and 18 deletions
|
|
@ -925,11 +925,16 @@ FORMAT_FLOAT(PyObject *value, PyObject *args)
|
|||
}
|
||||
|
||||
/* parse the format_spec */
|
||||
if (!parse_internal_render_format_spec(format_spec, &format, 'g'))
|
||||
if (!parse_internal_render_format_spec(format_spec, &format, '\0'))
|
||||
goto done;
|
||||
|
||||
/* type conversion? */
|
||||
switch (format.type) {
|
||||
case '\0':
|
||||
/* 'Z' means like 'g', but with at least one decimal. See
|
||||
PyOS_ascii_formatd */
|
||||
format.type = 'Z';
|
||||
/* Deliberate fall through to the next case statement */
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue