diff options
author | Eric Smith <eric@trueblade.com> | 2008-03-17 11:01:01 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-03-17 11:01:01 (GMT) |
commit | 8113ca63b948d059aac6678b70cce95ac0c59abd (patch) | |
tree | 51d08fcd71b93c962eb8b328a05ef569675d0538 /Objects/stringlib | |
parent | 43da35de7bfbdbcba26d7d4226835cc718c2de7d (diff) | |
download | cpython-8113ca63b948d059aac6678b70cce95ac0c59abd.zip cpython-8113ca63b948d059aac6678b70cce95ac0c59abd.tar.gz cpython-8113ca63b948d059aac6678b70cce95ac0c59abd.tar.bz2 |
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.
Diffstat (limited to 'Objects/stringlib')
-rw-r--r-- | Objects/stringlib/formatter.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h index e8e83f4..3ca14fa 100644 --- a/Objects/stringlib/formatter.h +++ b/Objects/stringlib/formatter.h @@ -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': |