bug fixing

This commit is contained in:
David Halter
2012-04-18 21:41:51 +02:00
parent ff7f774dc6
commit 0048eb65c4
8 changed files with 25 additions and 20 deletions

View File

@@ -42,7 +42,7 @@ class Parser(object):
name = os.path.basename(self.path)
self.name = name.rpartition('.')[0] # cut file type (normally .so)
self.path = os.path.dirname(self.path)
print self.name, self.path
#print self.name, self.path
self._content = {}
self._parser = None
self._module = None
@@ -54,13 +54,13 @@ class Parser(object):
self.sys_path.insert(0, self.path)
temp, sys.path = sys.path, self.sys_path
print 'sypa', sys.path
#print 'sypa', sys.path TODO reenable and check (stackoverflow ticket)
exec 'import %s as module' % self.name in self._content
self.sys_path, sys.path = sys.path, temp
self.sys_path.pop(0)
self._module = self._content['module']
print 'mod', self._content['module']
#print 'mod', self._content['module']
return self._module
@property
@@ -69,7 +69,7 @@ class Parser(object):
if not self._parser:
try:
timestamp, parser = Parser.cache[self.name, self.path]
if timestamp == os.path.getmtime(self.path):
if not self.path or timestamp == os.path.getmtime(self.path):
debug.dbg('hit builtin cache')
self._parser = parser
else:

View File

@@ -276,7 +276,7 @@ def strip_imports(scopes):
result = []
for s in scopes:
if isinstance(s, parsing.Import):
print 'dini mueter, steile griech!'
#print 'dini mueter, steile griech!'
try:
result += follow_import(s)
except modules.ModuleNotFound:

View File

@@ -2,7 +2,7 @@
import functions
#functions.debug.debug_function = functions.debug.print_to_stdout
functions.debug.debug_function = functions.debug.print_to_stdout
functions.debug.ignored_modules = ['parsing', 'builtin']
functions.debug.ignored_modules = ['parsing', 'builtin', 'evaluate', 'modules']
functions.modules.module_find_path.insert(0, '.')

View File

@@ -188,6 +188,7 @@ def complete(source, row, column, source_path):
except IndexError:
completions = evaluate.get_names_for_scope(scope)
else:
stmt.parent = scope
scopes = evaluate.follow_statement(stmt, scope)
completions = []

View File

@@ -147,4 +147,4 @@ c = b().c3()
1.0.fromhex(); import flask ; flsk = flask.Flask + flask.Request;
abc = [1,2+3]; abc[0].
import pylab
pylab.one
abc = datetime; return [abc][0].

View File

@@ -65,7 +65,7 @@ class Simple(object):
self.parent = None
def get_parent_until(self, *classes):
""" Takes always the parent, until one class """
""" Takes always the parent, until one class (not a Class) """
scope = self
while not (scope.parent is None or scope.__class__ in classes):
scope = scope.parent
@@ -209,14 +209,14 @@ class Scope(Simple):
def __repr__(self):
try:
name = self.name
except:
except AttributeError:
try:
name = self.command
except:
except AttributeError:
name = self.module_path
return "<%s: %s@%s-%s>" % \
(self.__class__.__name__, name, self.line_nr, self.line_end)
(self.__class__.__name__, name, self.line_nr, self.__hash__())
class GlobalScope(Scope):
@@ -242,8 +242,7 @@ class GlobalScope(Scope):
# set no parent here, because globals are not defined in this scope.
def get_set_vars(self):
n = []
n += super(GlobalScope, self).get_set_vars()
n = super(GlobalScope, self).get_set_vars()
n += self.global_vars
return n
@@ -321,10 +320,9 @@ class Function(Scope):
return str
def get_set_vars(self):
n = []
n = super(Function, self).get_set_vars()
for i, p in enumerate(self.params):
n += p.set_vars or p.used_vars
n += super(Function, self).get_set_vars()
return n
@@ -393,8 +391,7 @@ class Flow(Scope):
generate the output.
"""
if is_internal_call:
n = []
n += self.set_vars
n = list(self.set_vars)
if self.statement:
n += self.statement.set_vars
if self.next:
@@ -519,7 +516,7 @@ class Statement(Simple):
def get_set_vars(self):
""" Get the names for the statement. """
return self.set_vars
return list(self.set_vars)
def get_assignment_calls(self):
"""
@@ -1148,9 +1145,12 @@ class PyFuzzyParser(object):
if is_return:
# add returns to the scope
func = self.scope.get_parent_until(Function)
func.returns.append(stmt)
if is_return == 'yield':
func.is_generator = True
try:
func.returns.append(stmt)
except AttributeError:
debug.warning('return in non-function')
return stmt, tok

View File

@@ -1,3 +1,7 @@
#? ['imag']
[1,2][0].imag
a = list()
#? ['append']
[a][0].append

View File

@@ -49,7 +49,7 @@ def completion_test(source):
tests += 1
else:
try:
correct = re.search(r'#\?\s*([^\n]+)', line).group(1)
correct = re.search(r'(?:^|\s)#\?\s*([^\n]+)', line).group(1)
except:
correct = None
return tests, fails