forked from VimPlug/jedi
debug.dbg and debug.warning now take a string and format args parameters to make debugging a little bit cleaner
This commit is contained in:
+9
-13
@@ -269,11 +269,8 @@ class Parser(object):
|
||||
first_pos = self.start_pos
|
||||
token_type, cname = self.next()
|
||||
if token_type != tokenize.NAME:
|
||||
debug.warning(
|
||||
"class: syntax err, token is not a name@%s (%s: %s)" % (
|
||||
self.start_pos[0], tokenize.tok_name[token_type], cname
|
||||
)
|
||||
)
|
||||
debug.warning("class: syntax err, token is not a name@%s (%s: %s)",
|
||||
self.start_pos[0], tokenize.tok_name[token_type], cname)
|
||||
return None
|
||||
|
||||
cname = pr.Name(self.module, [(cname, self.start_pos)], self.start_pos,
|
||||
@@ -286,7 +283,7 @@ class Parser(object):
|
||||
token_type, _next = self.next()
|
||||
|
||||
if _next != ':':
|
||||
debug.warning("class syntax: %s@%s" % (cname, self.start_pos[0]))
|
||||
debug.warning("class syntax: %s@%s", cname, self.start_pos[0])
|
||||
return None
|
||||
|
||||
# because of 2 line class initializations
|
||||
@@ -446,8 +443,8 @@ class Parser(object):
|
||||
or self.user_scope is None
|
||||
and self.start_pos[0] >= self.user_position[0]
|
||||
):
|
||||
debug.dbg('user scope found [%s] = %s' %
|
||||
(self.parserline.replace('\n', ''), repr(self._scope)))
|
||||
debug.dbg('user scope found [%s] = %s',
|
||||
self.parserline.replace('\n', ''), self._scope)
|
||||
self.user_scope = self._scope
|
||||
|
||||
self._current = typ, tok
|
||||
@@ -473,8 +470,8 @@ class Parser(object):
|
||||
# This iterator stuff is not intentional. It grew historically.
|
||||
for token_type, tok in self.iterator:
|
||||
self.module.temp_used_names = []
|
||||
# debug.dbg('main: tok=[%s] type=[%s] indent=[%s]'\
|
||||
# % (tok, tokenize.tok_name[token_type], start_position[0]))
|
||||
# debug.dbg('main: tok=[%s] type=[%s] indent=[%s]', \
|
||||
# tok, tokenize.tok_name[token_type], start_position[0])
|
||||
|
||||
while token_type == tokenize.DEDENT and self._scope != self.module:
|
||||
token_type, tok = self.next()
|
||||
@@ -504,8 +501,7 @@ class Parser(object):
|
||||
if tok == 'def':
|
||||
func = self._parse_function()
|
||||
if func is None:
|
||||
debug.warning("function: syntax error@%s" %
|
||||
self.start_pos[0])
|
||||
debug.warning("function: syntax error@%s", self.start_pos[0])
|
||||
continue
|
||||
self.freshscope = True
|
||||
self._scope = self._scope.add_scope(func, self._decorators)
|
||||
@@ -549,7 +545,7 @@ class Parser(object):
|
||||
tok = 'import'
|
||||
mod = None
|
||||
if not mod and not relative_count or tok != "import":
|
||||
debug.warning("from: syntax error@%s" % self.start_pos[0])
|
||||
debug.warning("from: syntax error@%s", self.start_pos[0])
|
||||
defunct = True
|
||||
if tok != 'import':
|
||||
self._gen.push_last_back()
|
||||
|
||||
@@ -477,7 +477,7 @@ class Function(Scope):
|
||||
try:
|
||||
n.append(p.get_name())
|
||||
except IndexError:
|
||||
debug.warning("multiple names in param %s" % n)
|
||||
debug.warning("multiple names in param %s", n)
|
||||
return n
|
||||
|
||||
def get_call_signature(self, width=72, funcname=None):
|
||||
@@ -1018,12 +1018,12 @@ class Statement(Simple):
|
||||
|
||||
middle, tok = parse_stmt_or_arr(token_iterator, ['in'], True)
|
||||
if tok != 'in' or middle is None:
|
||||
debug.warning('list comprehension middle @%s' % str(start_pos))
|
||||
debug.warning('list comprehension middle @%s', start_pos)
|
||||
return None, tok
|
||||
|
||||
in_clause, tok = parse_stmt_or_arr(token_iterator)
|
||||
if in_clause is None:
|
||||
debug.warning('list comprehension in @%s' % str(start_pos))
|
||||
debug.warning('list comprehension in @%s', start_pos)
|
||||
return None, tok
|
||||
|
||||
return ListComprehension(st, middle, in_clause, self), tok
|
||||
@@ -1156,7 +1156,7 @@ class Param(Statement):
|
||||
""" get the name of the param """
|
||||
n = self.get_set_vars()
|
||||
if len(n) > 1:
|
||||
debug.warning("Multiple param names (%s)." % n)
|
||||
debug.warning("Multiple param names (%s).", n)
|
||||
return n[0]
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class UserContext(object):
|
||||
string += tok
|
||||
last_type = token_type
|
||||
except tokenize.TokenError:
|
||||
debug.warning("Tokenize couldn't finish", sys.exc_info)
|
||||
debug.warning("Tokenize couldn't finish: %s", sys.exc_info)
|
||||
|
||||
# string can still contain spaces at the end
|
||||
return string[::-1].strip(), start_cursor
|
||||
|
||||
Reference in New Issue
Block a user