Also document that some attributes may be None.
.. 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.
# 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