seems like compile is way slower than just parser.suite so
we try to see if it's available (only jython doesn't have it) --HG-- branch : trunk
This commit is contained in:
parent
518194537e
commit
734a40eb28
|
@ -157,12 +157,20 @@ class Source(object):
|
||||||
""" return True if source is parseable, heuristically
|
""" return True if source is parseable, heuristically
|
||||||
deindenting it by default.
|
deindenting it by default.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
import parser
|
||||||
|
except ImportError:
|
||||||
|
syntax_checker = lambda x: compile(x, 'asd', 'exec')
|
||||||
|
else:
|
||||||
|
syntax_checker = parser.suite
|
||||||
|
|
||||||
if deindent:
|
if deindent:
|
||||||
source = str(self.deindent())
|
source = str(self.deindent())
|
||||||
else:
|
else:
|
||||||
source = str(self)
|
source = str(self)
|
||||||
try:
|
try:
|
||||||
compile(source+'\n', "x", "exec")
|
#compile(source+'\n', "x", "exec")
|
||||||
|
syntax_checker(source+'\n')
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue