summaryrefslogtreecommitdiffstats
path: root/Lib/json/decoder.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-16 21:17:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-16 21:17:24 (GMT)
commita13d475901553b4a0ec7ed679ce2eac4598b557f (patch)
treedc0745a76b64e954cded961b6ec99bc08bdeac78 /Lib/json/decoder.py
parent60192084c405292f874d886eed05ed83614d20c4 (diff)
downloadcpython-a13d475901553b4a0ec7ed679ce2eac4598b557f.zip
cpython-a13d475901553b4a0ec7ed679ce2eac4598b557f.tar.gz
cpython-a13d475901553b4a0ec7ed679ce2eac4598b557f.tar.bz2
merge r66932 and add a few py3k only checks
Diffstat (limited to 'Lib/json/decoder.py')
-rw-r--r--Lib/json/decoder.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index f0bc245..4e88ba6 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -18,11 +18,15 @@ NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
def linecol(doc, pos):
- lineno = doc.count('\n', 0, pos) + 1
+ if isinstance(doc, bytes):
+ newline = b'\n'
+ else:
+ newline = '\n'
+ lineno = doc.count(newline, 0, pos) + 1
if lineno == 1:
colno = pos
else:
- colno = pos - doc.rindex('\n', 0, pos)
+ colno = pos - doc.rindex(newline, 0, pos)
return lineno, colno