<s> from test . test_support import verbose , have_unicode , TestFailed , check_impl_detail <EOL> import sys <EOL> from test . test_support import MAX_Py_ssize_t <EOL> maxsize = MAX_Py_ssize_t <EOL> overflowok = <NUM_LIT:1> <EOL> overflowrequired = <NUM_LIT:0> <EOL> def testformat ( formatstr , args , output = None ) : <EOL> if verbose : <EOL> if output : <EOL> print "<STR_LIT>" % ( repr ( formatstr ) , repr ( args ) , repr ( output ) ) , <EOL> else : <EOL> print "<STR_LIT>" % ( repr ( formatstr ) , repr ( args ) ) , <EOL> try : <EOL> result = formatstr % args <EOL> except ( OverflowError , MemoryError ) : <EOL> if not overflowok : <EOL> raise <EOL> if verbose : <EOL> print '<STR_LIT>' <EOL> else : <EOL> if overflowrequired : <EOL> if verbose : <EOL> print '<STR_LIT>' <EOL> print "<STR_LIT>" % ( repr ( formatstr ) , repr ( args ) ) <EOL> elif output and result != output : <EOL> if verbose : <EOL> print '<STR_LIT>' <EOL> print "<STR_LIT>" % ( repr ( formatstr ) , repr ( args ) , repr ( result ) , repr ( output ) ) <EOL> else : <EOL> if verbose : <EOL> print '<STR_LIT:yes>' <EOL> def testboth ( formatstr , * args ) : <EOL> testformat ( formatstr , * args ) <EOL> if have_unicode : <EOL> testformat ( unicode ( formatstr ) , * args ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT:1> , ) , "<STR_LIT:1>" ) <EOL> testboth ( "<STR_LIT>" , ( sys . maxint , <NUM_LIT:1> ) ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT:1> , ) , '<STR_LIT>' ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT:1> , ) , '<STR_LIT>' ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT:1> , ) , '<STR_LIT>' ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT:1.0> , ) , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> testboth ( '<STR_LIT>' , ( <NUM_LIT> , <NUM_LIT:1.0> ) ) <EOL> overflowrequired = <NUM_LIT:1> <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> testboth ( "<STR_LIT>" , ( <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ) ) <EOL> overflowrequired = <NUM_LIT:0> <EOL> overflowok = <NUM_LIT:0> <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:10> L , "<STR_LIT:a>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:10> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:10> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> L , "<STR_LIT>" ) <EOL> big = <NUM_LIT> L <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> big = <NUM_LIT> L <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> big = <NUM_LIT:0> <NUM_LIT> L <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , big , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - <NUM_LIT> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:1> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:1> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:1> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT:0>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> L , "<STR_LIT:0>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT:0>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> L , "<STR_LIT:0>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT:0>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> L , "<STR_LIT:0>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - <NUM_LIT> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> <NUM_LIT> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - <NUM_LIT:0> <NUM_LIT> , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , <NUM_LIT:0> <NUM_LIT> L , "<STR_LIT>" ) <EOL> testboth ( "<STR_LIT>" , - <NUM_LIT:0> <NUM_LIT> L , "<STR_LIT>" ) <EOL> if verbose : <EOL> print '<STR_LIT>' <EOL> def test_exc ( formatstr , args , exception , excmsg ) : <EOL> try : <EOL> testformat ( formatstr , args ) <EOL> except exception , exc : <EOL> if str ( exc ) == excmsg : <EOL> if verbose : <EOL> print "<STR_LIT:yes>" <EOL> else : <EOL> if verbose : print '<STR_LIT>' <EOL> print '<STR_LIT>' , exception , '<STR_LIT::>' , repr ( str ( exc ) ) <EOL> except : <EOL> if verbose : print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> raise <EOL> else : <EOL> raise TestFailed , '<STR_LIT>' % excmsg <EOL> test_exc ( '<STR_LIT>' , <NUM_LIT:1> , ValueError , <EOL> "<STR_LIT>" ) <EOL> if have_unicode : <EOL> test_exc ( unicode ( '<STR_LIT>' , '<STR_LIT>' ) , <NUM_LIT:1> , ValueError , <EOL> "<STR_LIT>" ) <EOL> test_exc ( '<STR_LIT>' , '<STR_LIT:1>' , TypeError , "<STR_LIT>" ) <EOL> test_exc ( '<STR_LIT>' , '<STR_LIT:1>' , TypeError , "<STR_LIT>" ) <EOL> test_exc ( '<STR_LIT>' , '<STR_LIT:1>' , TypeError , <EOL> "<STR_LIT>" ) <EOL> test_exc ( '<STR_LIT>' , u'<STR_LIT:1>' , TypeError , <EOL> "<STR_LIT>" ) <EOL> test_exc ( u'<STR_LIT>' , '<STR_LIT:1>' , TypeError , <EOL> "<STR_LIT>" ) <EOL> test_exc ( u'<STR_LIT>' , u'<STR_LIT:1>' , TypeError , <EOL> "<STR_LIT>" ) <EOL> class Foobar ( long ) : <EOL> def __oct__ ( self ) : <EOL> return self + <NUM_LIT:1> <EOL> if check_impl_detail ( ) : <EOL> test_exc ( '<STR_LIT>' , Foobar ( ) , TypeError , <EOL> "<STR_LIT>" ) <EOL> if maxsize == <NUM_LIT:2> ** <NUM_LIT> - <NUM_LIT:1> : <EOL> try : <EOL> "<STR_LIT>" % ( maxsize , - <NUM_LIT> ) <EOL> except ( MemoryError , OverflowError ) : <EOL> pass <EOL> else : <EOL> raise TestFailed , '<STR_LIT>' </s>
