Mercurial > cpython-lru_cache-weakref
diff Objects/stringlib/formatter.h @ 45785:4d29127f3fa0 legacy-trunk
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.
| author | Eric Smith <eric@trueblade.com> |
|---|---|
| date | Mon, 17 Mar 2008 11:01:01 +0000 |
| parents | 5d726da21d75 |
| children | 4e72489f16d0 |
line wrap: on
line diff
--- a/Objects/stringlib/formatter.h Mon Mar 17 08:28:15 2008 +0000 +++ b/Objects/stringlib/formatter.h Mon Mar 17 11:01:01 2008 +0000 @@ -925,11 +925,16 @@ } /* 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':
