@@ -238,8 +238,11 @@ def test_compile(self):
238238 self .assertRaises (TypeError , compile )
239239 self .assertRaises (ValueError , compile , 'print 42\n ' , '<string>' , 'badmode' )
240240 self .assertRaises (ValueError , compile , 'print 42\n ' , '<string>' , 'single' , 0xff )
241+ self .assertRaises (TypeError , compile , chr (0 ), 'f' , 'exec' )
241242 if have_unicode :
242243 compile (unicode ('print u"\xc3 \xa5 "\n ' , 'utf8' ), '' , 'exec' )
244+ self .assertRaises (TypeError , compile , unichr (0 ), 'f' , 'exec' )
245+ self .assertRaises (ValueError , compile , unicode ('a = 1' ), 'f' , 'bad' )
243246
244247 def test_delattr (self ):
245248 import sys
@@ -421,6 +424,7 @@ def __setitem__(self, key, value):
421424
422425 unlink (TESTFN )
423426 self .assertRaises (TypeError , execfile )
427+ self .assertRaises (TypeError , execfile , TESTFN , {}, ())
424428 import os
425429 self .assertRaises (IOError , execfile , os .curdir )
426430 self .assertRaises (IOError , execfile , "I_dont_exist" )
@@ -1008,6 +1012,9 @@ class BadSeq:
10081012 def __getitem__ (self , index ):
10091013 raise ValueError
10101014 self .assertRaises (ValueError , map , lambda x : x , BadSeq ())
1015+ def badfunc (x ):
1016+ raise RuntimeError
1017+ self .assertRaises (RuntimeError , map , badfunc , range (5 ))
10111018
10121019 def test_max (self ):
10131020 self .assertEqual (max ('123123' ), '3' )
@@ -1239,6 +1246,12 @@ def test_range(self):
12391246 self .assertRaises (TypeError , range )
12401247 self .assertRaises (TypeError , range , 1 , 2 , 3 , 4 )
12411248 self .assertRaises (ValueError , range , 1 , 2 , 0 )
1249+ self .assertRaises (ValueError , range , a , a + 1 , long (0 ))
1250+
1251+ class badzero (int ):
1252+ def __cmp__ (self , other ):
1253+ raise RuntimeError
1254+ self .assertRaises (RuntimeError , range , a , a + 1 , badzero (1 ))
12421255
12431256 # Reject floats when it would require PyLongs to represent.
12441257 # (smaller floats still accepted, but deprecated)
0 commit comments