New submission from Florent Xicluna: I noticed a difference between computation of column offset for SyntaxError and IndentationError (a subclass of SyntaxError). It is slightly confusing.
def report(exc): print('lineno %s, offset %s' % (exc.lineno, exc.offset)) raise try: exec('except IOError:') except Exception as e: report(e) try: exec(' open(filepath)') except Exception as e: report(e) ** OUTPUT ** lineno 1, offset 6 Traceback (most recent call last): File "<stdin>", line 4, in <module> File "<stdin>", line 2, in <module> File "<string>", line 1 except IOError: ^ SyntaxError: invalid syntax lineno 1, offset 4 Traceback (most recent call last): File "<stdin>", line 4, in <module> File "<stdin>", line 2, in <module> File "<string>", line 1 open(filepath) ^ IndentationError: unexpected indent ** Analysis ** Case (1): offset is 6, and caret is below column 5 for SyntaxError Case (2): offset is 4, and caret is below column 4 for IndentationError ---------- messages: 187690 nosy: flox priority: normal severity: normal status: open title: Indentation.offset and SyntaxError.offset mismatch type: behavior versions: Python 2.7, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17825> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com