Don't use fancy new Python features like 'with' - some bots don't have them

and can't bootstrap the parser.
This commit is contained in:
Eli Bendersky 2013-09-26 06:41:36 -07:00
parent 58fe1b1307
commit 99081238e9
1 changed files with 4 additions and 1 deletions

View File

@ -398,8 +398,11 @@ def parse(file):
scanner = ASDLScanner()
parser = ASDLParser()
with open(file) as f:
try:
f = open(file)
buf = f.read()
finally:
f.close()
tokens = scanner.tokenize(buf)
try:
return parser.parse(tokens)