def verify_source(source): tree = fix_tree(parse(source, 'exec')) code = pycodegen.ModuleCodeGenerator(tree).getCode() generator = ModuleSourceCodeGenerator(tree) source = generator.getSourceCode() tree = fix_tree(parse(source, 'exec')) if code.co_code != pycodegen.ModuleCodeGenerator(tree).getCode().co_code: return source
def verify_source(source): tree = fix_tree(parse(source, 'exec')) code = pycodegen.ModuleCodeGenerator(tree).getCode() generator = ModuleSourceCodeGenerator(tree) generated = generator.getSourceCode() try: new = fix_tree(parse(generated, 'exec')) except SyntaxError: return generated old = code.co_code new = pycodegen.ModuleCodeGenerator(new).getCode().co_code if old != new: return generated