mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
merge r66932 and add a few py3k only checks
This commit is contained in:
parent
60192084c4
commit
a13d475901
3 changed files with 19 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue