'succeed iff str is the start of an invalid piece of code'

def assertInvalid(self, str, symbol='single', is_syntax=1):

    try:
        compile_command(str, symbol=symbol)
        self.fail('No    exception    thrown    for    invalid    code')
    except SyntaxError:
        self.assertTrue(is_syntax)
    except OverflowError:
        self.assertTrue((not is_syntax))
