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.
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 @@
}
/* 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':