Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv14562/Lib/test Modified Files: test_string.py test_unicode.py Log Message: Patch for bug #659709: bogus computation of float length Python 2.2.x backport candidate. (This bug has been around since Python 1.6.) Index: test_string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_string.py 9 Aug 2002 01:37:06 -0000 1.20 --- test_string.py 29 Dec 2002 19:44:06 -0000 1.21 *************** *** 58,59 **** --- 58,85 ---- 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 + Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** test_unicode.py 18 Nov 2002 16:11:34 -0000 1.73 --- test_unicode.py 29 Dec 2002 19:44:06 -0000 1.74 *************** *** 477,480 **** --- 477,505 ---- print '*** formatting u"%%c" %% %i should give a ValueError' % ordinal + # 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 + # formatting jobs delegated from the string implementation: verify('...%(foo)s...' % {'foo':u"abc"} == u'...abc...')
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4