mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
print and exec are no longer available, the parser removes them now.
This commit is contained in:
@@ -533,7 +533,6 @@ class PyFuzzyParser(object):
|
|||||||
if tok == 'in':
|
if tok == 'in':
|
||||||
break
|
break
|
||||||
|
|
||||||
print 'for_tok', tok
|
|
||||||
token_type, tok, indent = self.next()
|
token_type, tok, indent = self.next()
|
||||||
return (value_list, tok)
|
return (value_list, tok)
|
||||||
|
|
||||||
@@ -710,7 +709,7 @@ class PyFuzzyParser(object):
|
|||||||
breaks += added_breaks
|
breaks += added_breaks
|
||||||
|
|
||||||
while not (tok in always_break or tok in breaks and level <= 0):
|
while not (tok in always_break or tok in breaks and level <= 0):
|
||||||
set_string = ''
|
set_string = None
|
||||||
#print 'parse_stmt', tok, token.tok_name[token_type]
|
#print 'parse_stmt', tok, token.tok_name[token_type]
|
||||||
if tok == 'as':
|
if tok == 'as':
|
||||||
string += " %s " % tok
|
string += " %s " % tok
|
||||||
@@ -728,8 +727,9 @@ class PyFuzzyParser(object):
|
|||||||
set_string = ''
|
set_string = ''
|
||||||
elif tok in ['return', 'yield', 'del', 'raise', 'assert']:
|
elif tok in ['return', 'yield', 'del', 'raise', 'assert']:
|
||||||
set_string = tok + ' '
|
set_string = tok + ' '
|
||||||
elif tok == 'print':
|
elif tok in ['print', 'exec']:
|
||||||
set_string = tok + ' '
|
# delete those statements, just let the rest stand there
|
||||||
|
set_string = ''
|
||||||
else:
|
else:
|
||||||
path, token_type, tok, start_indent = \
|
path, token_type, tok, start_indent = \
|
||||||
self._parsedotname(self.current)
|
self._parsedotname(self.current)
|
||||||
@@ -740,7 +740,7 @@ class PyFuzzyParser(object):
|
|||||||
else:
|
else:
|
||||||
if not n.names[0] in ['global']:
|
if not n.names[0] in ['global']:
|
||||||
used_vars.append(n)
|
used_vars.append(n)
|
||||||
if string and re.match(r'[\w\d]', string[-1]):
|
if string and re.match(r'[\w\d\'"]', string[-1]):
|
||||||
string += ' '
|
string += ' '
|
||||||
string += ".".join(path)
|
string += ".".join(path)
|
||||||
#print 'parse_stmt', tok, token.tok_name[token_type]
|
#print 'parse_stmt', tok, token.tok_name[token_type]
|
||||||
@@ -754,7 +754,7 @@ class PyFuzzyParser(object):
|
|||||||
elif tok in ['}', ')', ']']:
|
elif tok in ['}', ')', ']']:
|
||||||
level -= 1
|
level -= 1
|
||||||
|
|
||||||
if set_string:
|
if set_string is not None:
|
||||||
string = set_string
|
string = set_string
|
||||||
else:
|
else:
|
||||||
string += tok
|
string += tok
|
||||||
|
|||||||
4
test.py
4
test.py
@@ -72,6 +72,8 @@ def ass_test(a):
|
|||||||
# (comment without indent)
|
# (comment without indent)
|
||||||
(b, c, d) = (1,2,3)
|
(b, c, d) = (1,2,3)
|
||||||
del b
|
del b
|
||||||
|
f = {}
|
||||||
|
exec 'a = 999' in f
|
||||||
# test strange statements
|
# test strange statements
|
||||||
[a,c] ; {1: a}; (1,); `a`
|
[a,c] ; {1: a}; (1,); `a`
|
||||||
result = int((a+b)*2)
|
result = int((a+b)*2)
|
||||||
@@ -105,7 +107,7 @@ def flow_test(a):
|
|||||||
raise e
|
raise e
|
||||||
yield e
|
yield e
|
||||||
#except TypeError, e:
|
#except TypeError, e:
|
||||||
# pass
|
pass
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user