summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-11-03 07:23:46 (GMT)
committerGitHub <noreply@github.com>2022-11-03 07:23:46 (GMT)
commite9ac890c0273aee413aa528cc202c3efa29f1d7a (patch)
treee9dc563c58e25de5dd3f5b592fa5575ea486349d /Doc
parent41bc101dd6726edc5fbd4a934ea057ec712d5498 (diff)
downloadcpython-e9ac890c0273aee413aa528cc202c3efa29f1d7a.zip
cpython-e9ac890c0273aee413aa528cc202c3efa29f1d7a.tar.gz
cpython-e9ac890c0273aee413aa528cc202c3efa29f1d7a.tar.bz2
gh-98740: Fix validation of conditional expressions in RE (GH-98764)
In very rare circumstances the JUMP opcode could be confused with the argument of the opcode in the "then" part which doesn't end with the JUMP opcode. This led to incorrect detection of the final JUMP opcode and incorrect calculation of the size of the subexpression. NOTE: Changed return value of functions _validate_inner() and _validate_charset() in Modules/_sre/sre.c. Now they return 0 on success, -1 on failure, and 1 if the last op is JUMP (which usually is a failure). Previously they returned 1 on success and 0 on failure.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/re.rst3
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 5b304f7..0e7dda0 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -483,6 +483,9 @@ The special characters are:
some fixed length. Patterns which start with negative lookbehind assertions may
match at the beginning of the string being searched.
+.. _re-conditional-expression:
+.. index:: single: (?(; in regular expressions
+
``(?(id/name)yes-pattern|no-pattern)``
Will try to match with ``yes-pattern`` if the group with given *id* or
*name* exists, and with ``no-pattern`` if it doesn't. ``no-pattern`` is