diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-10 11:49:00 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-10 11:49:00 (GMT) |
commit | ad446d57a929a642644c3a86c7359ce1638077b0 (patch) | |
tree | fb31d0b7aa5e3d09f5370c606d988d06c30b925f /Doc/library/re.rst | |
parent | eb99e5157498ae37117a54cdb01fea082d842a0d (diff) | |
download | cpython-ad446d57a929a642644c3a86c7359ce1638077b0.zip cpython-ad446d57a929a642644c3a86c7359ce1638077b0.tar.gz cpython-ad446d57a929a642644c3a86c7359ce1638077b0.tar.bz2 |
Issue #22578: Added attributes to the re.error class.
Diffstat (limited to 'Doc/library/re.rst')
-rw-r--r-- | Doc/library/re.rst | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 9268eb2..d1823aa 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -733,13 +733,36 @@ form. Clear the regular expression cache. -.. exception:: error +.. exception:: error(msg, pattern=None, pos=None) Exception raised when a string passed to one of the functions here is not a valid regular expression (for example, it might contain unmatched parentheses) or when some other error occurs during compilation or matching. It is never an - error if a string contains no match for a pattern. + error if a string contains no match for a pattern. The error instance has + the following additional attributes: + .. attribute:: msg + + The unformatted error message. + + .. attribute:: pattern + + The regular expression pattern. + + .. attribute:: pos + + The index of *pattern* where compilation failed. + + .. attribute:: lineno + + The line corresponding to *pos*. + + .. attribute:: colno + + The column corresponding to *pos*. + + .. versionchanged:: 3.5 + Added additional attributes. .. _re-objects: |