New submission from Ferdinand Beyer:

The linecol() function in json/decoder.py computes the line and column numbers 
for a byte offset in a string.  Both numbers are expected to start with 1 (as 
in text editors).

If the position is in the first line, the returned column is off by one (or 
starting with zero):

    >>> from json.decoder import linecol
    >>> linecol('spam', 0)  # Should be (1, 1)
    (1, 0)
    >>> linecol('\nspam', 1)
    (2, 1)

The problem is the line:

    if lineno == 1:
        colno = pos

that should read

    if lineno == 1:
        colno = pos + 1

----------
components: Library (Lib)
messages: 182320
nosy: fbeyer
priority: normal
severity: normal
status: open
title: JSON decoder reports wrong column number on first line
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17225>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to