summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2013-11-12 18:36:47 -0700
committerAaron Meurer <asmeurer@gmail.com>2013-11-12 18:36:47 -0700
commit3e82edf89123e7267676ab065f4e2a88660cf2db (patch)
treeb6e32c13905dbda3f33dfefcf2f6667aa51ebb46
parent6dce640d3b5a51d7717ff832d7f0c0bc81f9d94d (diff)
downloadpyflakes-3e82edf89123e7267676ab065f4e2a88660cf2db.tar.gz
Handle syntax error offset being None
-rw-r--r--pyflakes/reporter.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/pyflakes/reporter.py b/pyflakes/reporter.py
index f6ee7e9..74f9f2e 100644
--- a/pyflakes/reporter.py
+++ b/pyflakes/reporter.py
@@ -45,7 +45,7 @@ class Reporter(object):
@ptype msg: C{unicode}
@param lineno: The line number where the syntax error occurred.
@ptype lineno: C{int}
- @param offset: The column on which the syntax error occurred.
+ @param offset: The column on which the syntax error occurred, or None.
@ptype offset: C{int}
@param text: The source code containing the syntax error.
@ptype text: C{unicode}
@@ -53,7 +53,10 @@ class Reporter(object):
line = text.splitlines()[-1]
if offset is not None:
offset = offset - (len(text) - len(line))
- self._stderr.write('%s:%d:%d: %s\n' % (filename, lineno, offset, msg))
+ self._stderr.write('%s:%d:%d: %s\n' % (filename, lineno, offset,
+ msg))
+ else:
+ self._stderr.write('%s:%d: %s\n' % (filename, lineno, msg))
self._stderr.write(line)
self._stderr.write('\n')
if offset is not None: