]> granicus.if.org Git - python/commitdiff
[3.5] bpo-30398: Add a docstring for re.error. (GH-1647) (#1831)
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 27 May 2017 13:38:12 +0000 (16:38 +0300)
committerGitHub <noreply@github.com>
Sat, 27 May 2017 13:38:12 +0000 (16:38 +0300)
Also document that some attributes may be None.
(cherry picked from commit 12d6b5d)

Doc/library/re.rst
Lib/sre_constants.py

index d33fff8ef3217bad0a92bdb1a62cec5fb628a5d0..26d25582c72a86adb40a0a6e190bab01361e0489 100644 (file)
@@ -815,15 +815,15 @@ form.
 
    .. attribute:: pos
 
-      The index of *pattern* where compilation failed.
+      The index in *pattern* where compilation failed (may be ``None``).
 
    .. attribute:: lineno
 
-      The line corresponding to *pos*.
+      The line corresponding to *pos* (may be ``None``).
 
    .. attribute:: colno
 
-      The column corresponding to *pos*.
+      The column corresponding to *pos* (may be ``None``).
 
    .. versionchanged:: 3.5
       Added additional attributes.
index fc684ae96fd30a67ca129628663d769912e0a9d7..a6e8a1f08d68a8aa083efd171f7d51ff1bab1b94 100644 (file)
@@ -21,6 +21,17 @@ from _sre import MAXREPEAT, MAXGROUPS
 # should this really be here?
 
 class error(Exception):
+    """Exception raised for invalid regular expressions.
+
+    Attributes:
+
+        msg: The unformatted error message
+        pattern: The regular expression pattern
+        pos: The index in the pattern where compilation failed (may be None)
+        lineno: The line corresponding to pos (may be None)
+        colno: The column corresponding to pos (may be None)
+    """
+
     def __init__(self, msg, pattern=None, pos=None):
         self.msg = msg
         self.pattern = pattern