Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions python/ccxt/static_dependencies/parsimonious/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from .utils import StrAndRepr


Expand Down Expand Up @@ -35,10 +34,14 @@ def line(self):
def column(self):
"""Return the 1-based column where the expression ceased to match."""
# We choose 1-based because that's what Python does with SyntaxErrors.
try:
return self.pos - self.text.rindex('\n', 0, self.pos)
except ValueError:
return self.pos + 1
pos = self.pos
if pos == 0:
return 1
# Avoid exception handling overhead by explicitly checking
last_newline = self.text.rfind('\n', 0, pos)
if last_newline == -1:
return pos + 1
return pos - last_newline


class IncompleteParseError(ParseError):
Expand Down