Skip to content

Commit b2a91e0

Browse files
authored
bpo-43705: Document that SyntaxError's offsets are 1-indexed (GH-25153)
Changed the inline mentions of the attributes into a proper attribute list like `SystemExit` has. Automerge-Triggered-By: GH:gvanrossum
1 parent f97dc80 commit b2a91e0

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Doc/library/exceptions.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,25 @@ The following exceptions are the exceptions that are usually raised.
402402
or :func:`eval`, or when reading the initial script or standard input
403403
(also interactively).
404404

405-
Instances of this class have attributes :attr:`filename`, :attr:`lineno`,
406-
:attr:`offset` and :attr:`text` for easier access to the details. :func:`str`
407-
of the exception instance returns only the message.
405+
The :func:`str` of the exception instance returns only the error message.
406+
407+
.. attribute:: filename
408+
409+
The name of the file the syntax error occurred in.
410+
411+
.. attribute:: lineno
412+
413+
Which line number in the file the error occurred in. This is
414+
1-indexed: the first line in the file has a ``lineno`` of 1.
415+
416+
.. attribute:: offset
417+
418+
The column in the line where the error occurred. This is
419+
1-indexed: the first character in the line has an ``offset`` of 1.
420+
421+
.. attribute:: text
422+
423+
The source code text involved in the error.
408424

409425

410426
.. exception:: IndentationError

0 commit comments

Comments
 (0)