mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
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
(cherry picked from commit b2a91e0c9e
)
Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
This commit is contained in:
parent
9350cc02f8
commit
63c69440c7
1 changed files with 19 additions and 3 deletions
|
@ -397,9 +397,25 @@ The following exceptions are the exceptions that are usually raised.
|
||||||
or :func:`eval`, or when reading the initial script or standard input
|
or :func:`eval`, or when reading the initial script or standard input
|
||||||
(also interactively).
|
(also interactively).
|
||||||
|
|
||||||
Instances of this class have attributes :attr:`filename`, :attr:`lineno`,
|
The :func:`str` of the exception instance returns only the error message.
|
||||||
:attr:`offset` and :attr:`text` for easier access to the details. :func:`str`
|
|
||||||
of the exception instance returns only the message.
|
.. attribute:: filename
|
||||||
|
|
||||||
|
The name of the file the syntax error occurred in.
|
||||||
|
|
||||||
|
.. attribute:: lineno
|
||||||
|
|
||||||
|
Which line number in the file the error occurred in. This is
|
||||||
|
1-indexed: the first line in the file has a ``lineno`` of 1.
|
||||||
|
|
||||||
|
.. attribute:: offset
|
||||||
|
|
||||||
|
The column in the line where the error occurred. This is
|
||||||
|
1-indexed: the first character in the line has an ``offset`` of 1.
|
||||||
|
|
||||||
|
.. attribute:: text
|
||||||
|
|
||||||
|
The source code text involved in the error.
|
||||||
|
|
||||||
|
|
||||||
.. exception:: IndentationError
|
.. exception:: IndentationError
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue