From 03a6bf6b59fbf8683126792583c57e8aafc38a68 Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 29 Mar 2012 02:11:34 +0200 Subject: [PATCH] debug warnings are now also possible --- debug.py | 3 +++ parsing.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/debug.py b/debug.py index 29dc2505..66899168 100644 --- a/debug.py +++ b/debug.py @@ -7,6 +7,9 @@ def dbg(*args): if not (mod.__name__ in ignored_modules): debug_function(*args) +def warning(*args): + if debug_function: + debug_function(*args) debug_function = None ignored_modules = [] diff --git a/parsing.py b/parsing.py index e162bb1c..4060368d 100644 --- a/parsing.py +++ b/parsing.py @@ -904,7 +904,7 @@ class PyFuzzyParser(object): """ names = [] tok = None - while tok not in [')', '\n', ':']: + while tok not in [')', ':']: stmt, tok = self._parse_statement(added_breaks=',') if stmt: names.append(stmt) @@ -1124,7 +1124,7 @@ class PyFuzzyParser(object): while indent <= self.scope.indent \ and token_type in [tokenize.NAME] \ and self.scope != self.top: - debug.dbg('syntax_err, dedent @%s - %s<=%s', \ + debug.warning('syntax_err, dedent @%s - %s<=%s', \ (self.line_nr, indent, self.scope.indent)) self.scope.line_end = self.line_nr self.scope = self.scope.parent @@ -1133,7 +1133,8 @@ class PyFuzzyParser(object): if tok == 'def': func = self._parsefunction(indent) if func is None: - print "function: syntax error@%s" % self.line_nr + debug.warning("function: syntax error@%s" % + self.line_nr) continue debug.dbg("new scope: function %s" % (func.name)) freshscope = True @@ -1142,6 +1143,8 @@ class PyFuzzyParser(object): elif tok == 'class': cls = self._parseclass(indent) if cls is None: + debug.warning("class: syntax error@%s" % + self.line_nr) continue freshscope = True debug.dbg("new scope: class %s" % (cls.name)) @@ -1158,7 +1161,8 @@ class PyFuzzyParser(object): mod, token_type, tok, start_indent, start_line2 = \ self._parsedotname() if not mod or tok != "import": - print "from: syntax error..." + debug.warning("from: syntax error@%s" % + self.line_nr) continue mod = Name(mod, start_indent, start_line2, self.line_nr) names = self._parseimportlist()