summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-03-17 11:01:01 (GMT)
committerEric Smith <eric@trueblade.com>2008-03-17 11:01:01 (GMT)
commit8113ca63b948d059aac6678b70cce95ac0c59abd (patch)
tree51d08fcd71b93c962eb8b328a05ef569675d0538 /Lib
parent43da35de7bfbdbcba26d7d4226835cc718c2de7d (diff)
downloadcpython-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 'Lib')
-rw-r--r--Lib/test/test_types.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index bf218db..4fa2c01 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -521,6 +521,15 @@ class TypesTests(unittest.TestCase):
test(1.1234e20, 'e', '1.123400e+20')
test(1.1234e20, 'E', '1.123400E+20')
+ # No format code means use g, but must have a decimal
+ # and a number after the decimal. This is tricky, because
+ # a totaly empty format specifier means something else.
+ # So, just use a sign flag
+ test(1e200, '+g', '+1e+200')
+ test(1e200, '+', '+1.0e+200')
+ test(1.1e200, '+g', '+1.1e+200')
+ test(1.1e200, '+', '+1.1e+200')
+
# % formatting
test(-1.0, '%', '-100.000000%')