]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43705: Document that SyntaxError's offsets are 1-indexed (GH-25153)
authorAmmar Askar <ammar@ammaraskar.com>
Fri, 2 Apr 2021 21:25:31 +0000 (17:25 -0400)
committerGitHub <noreply@github.com>
Fri, 2 Apr 2021 21:25:31 +0000 (14:25 -0700)
Changed the inline mentions of the attributes into a proper attribute list like `SystemExit` has.

Automerge-Triggered-By: GH:gvanrossum
Doc/library/exceptions.rst

index 40ccde72d07cc3a1e06cb061d6213cdc4bdfa41f..4dea6701a6bfd08f2d4cb98d732a405ee7284277 100644 (file)
@@ -402,9 +402,25 @@ The following exceptions are the exceptions that are usually raised.
    or :func:`eval`, or when reading the initial script or standard input
    (also interactively).
 
-   Instances of this class have attributes :attr:`filename`, :attr:`lineno`,
-   :attr:`offset` and :attr:`text` for easier access to the details.  :func:`str`
-   of the exception instance returns only the message.
+   The :func:`str` of the exception instance returns only the error 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