From 72af5f5db3be89a06b825536d1810d3f3908455e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 6 Feb 2015 22:07:40 -0800 Subject: [PATCH] Issue #23404: Do not use Python 2.7 constructs in Parser/asdl.py. This patch fixes a build error when using a Python 2.6 toolchain. python ./Parser/asdl_c.py -h Include ./Parser/Python.asdl Traceback (most recent call last): File "./Parser/asdl_c.py", line 6, in import asdl File "Parser/asdl.py", line 36 builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton'} ^ SyntaxError: invalid syntax Signed-off-by: Vinson Lee --- Parser/asdl.py | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Parser/asdl.py b/Parser/asdl.py index 121cdab..12a7bb9 100644 --- a/Parser/asdl.py +++ b/Parser/asdl.py @@ -33,7 +33,8 @@ __all__ = [ # See the EBNF at the top of the file to understand the logical connection # between the various node types. -builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton'} +builtin_types = set( + ['identifier', 'string', 'bytes', 'int', 'object', 'singleton']) class AST: def __repr__(self): @@ -43,7 +44,9 @@ class Module(AST): def __init__(self, name, dfns): self.name = name self.dfns = dfns - self.types = {type.name: type.value for type in dfns} + self.types = {} + for type in dfns: + self.types[type.name] = type.value def __repr__(self): return 'Module({0.name}, {0.dfns})'.format(self) -- 1.7.1