[Python-checkins] python/dist/src/Lib/test test_string.py,1.15.6.2,1.15.6.3

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Thu, 02 Jan 2003 14:09:08 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv3455/Lib/test

Modified Files:
      Tag: release22-maint
	test_string.py 
Log Message:
Backport MAL's patch for bug #659709: bogus computation of float length



Index: test_string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v
retrieving revision 1.15.6.2
retrieving revision 1.15.6.3
diff -C2 -d -r1.15.6.2 -r1.15.6.3
*** test_string.py	7 Oct 2002 01:18:17 -0000	1.15.6.2
--- test_string.py	2 Jan 2003 22:08:32 -0000	1.15.6.3
***************
*** 56,57 ****
--- 56,83 ----
  string.lowercase
  string.uppercase
+ 
+ # Float formatting
+ for prec in range(100):
+     formatstring = u'%%.%if' % prec
+     value = 0.01
+     for x in range(60):
+         value = value * 3.141592655 / 3.0 * 10.0
+         #print 'Overflow check for x=%i and prec=%i:' % \
+         #      (x, prec),
+         try:
+             result = formatstring % value
+         except OverflowError:
+             # The formatfloat() code in stringobject.c and
+             # unicodeobject.c uses a 120 byte buffer and switches from
+             # 'f' formatting to 'g' at precision 50, so we expect
+             # OverflowErrors for the ranges x < 50 and prec >= 67.
+             if x >= 50 or \
+                prec < 67:
+                 print '*** unexpected OverflowError for x=%i and prec=%i' % (x, prec)
+             else:
+                 #print 'OverflowError'
+                 pass
+         else:
+             #print result
+             pass
+