try: eval(b'\xc2\xa1'.decode('utf-8')) except SyntaxError as err: assert(err.offset == 1)