Kaydet (Commit) 12d6b5d1 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka Kaydeden (comit) GitHub

bpo-30398: Add a docstring for re.error. (#1647)

Also document that some attributes may be None.
üst 5becf38a
...@@ -839,15 +839,15 @@ form. ...@@ -839,15 +839,15 @@ form.
.. attribute:: pos .. attribute:: pos
The index of *pattern* where compilation failed. The index in *pattern* where compilation failed (may be ``None``).
.. attribute:: lineno .. attribute:: lineno
The line corresponding to *pos*. The line corresponding to *pos* (may be ``None``).
.. attribute:: colno .. attribute:: colno
The column corresponding to *pos*. The column corresponding to *pos* (may be ``None``).
.. versionchanged:: 3.5 .. versionchanged:: 3.5
Added additional attributes. Added additional attributes.
......
...@@ -21,6 +21,17 @@ from _sre import MAXREPEAT, MAXGROUPS ...@@ -21,6 +21,17 @@ from _sre import MAXREPEAT, MAXGROUPS
# should this really be here? # should this really be here?
class error(Exception): 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): def __init__(self, msg, pattern=None, pos=None):
self.msg = msg self.msg = msg
self.pattern = pattern self.pattern = pattern
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment