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

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

index 96338dc27b2e6b6a5f38812b728c25b4886d3d57..0b9d9755f30ec658a068f4415edd24a376dc54a1 100644 (file)
@@ -839,15 +839,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 b0164312d0357e66608710a97705fbc6824eeb43..0261e9e956cbce94ed705f16bf117f404daa0a35 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