]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91870: Remove unsupported SRE opcode CALL (GH-91872)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 26 Apr 2022 18:07:25 +0000 (21:07 +0300)
committerGitHub <noreply@github.com>
Tue, 26 Apr 2022 18:07:25 +0000 (21:07 +0300)
It was initially added to support atomic groups, but that
support was never fully implemented, and CALL was only left
in the compiler, but not interpreter and parser.

ATOMIC_GROUP is now used to support atomic groups.

Lib/re/_compiler.py
Lib/re/_constants.py
Lib/re/_parser.py
Modules/_sre/sre_constants.h
Modules/_sre/sre_lib.h
Modules/_sre/sre_targets.h

index f621d04af123d4c1a4c0a88b8afc55336ba3af9f..63d82025505b74ed11e319def75d435bcd859dd2 100644 (file)
@@ -164,12 +164,6 @@ def _compile(data, pattern, flags):
             _compile(data, av[1], flags)
             emit(SUCCESS)
             code[skip] = _len(code) - skip
-        elif op is CALL:
-            emit(op)
-            skip = _len(code); emit(0)
-            _compile(data, av, flags)
-            emit(SUCCESS)
-            code[skip] = _len(code) - skip
         elif op is AT:
             emit(op)
             if flags & SRE_FLAG_MULTILINE:
index aa1a590290fd9c6e9e3767ee82fb57e588973d0c..c45ce409e21b85d5aa314f5fd3f03773f8ad9e31 100644 (file)
@@ -13,7 +13,7 @@
 
 # update when constants are added or removed
 
-MAGIC = 20220402
+MAGIC = 20220423
 
 from _sre import MAXREPEAT, MAXGROUPS
 
@@ -78,7 +78,6 @@ OPCODES = _makecodes(
     'ASSERT', 'ASSERT_NOT',
     'AT',
     'BRANCH',
-    'CALL',
     'CATEGORY',
     'CHARSET', 'BIGCHARSET',
     'GROUPREF', 'GROUPREF_EXISTS',
index b864bf2b108a6f7f8847f4d46952b65681164913..933d51589f46c79fda85b635588cfa8668deecac 100644 (file)
@@ -183,10 +183,6 @@ class SubPattern:
                     j = max(j, h)
                 lo = lo + i
                 hi = hi + j
-            elif op is CALL:
-                i, j = av.getwidth()
-                lo = lo + i
-                hi = hi + j
             elif op is ATOMIC_GROUP:
                 i, j = av.getwidth()
                 lo = lo + i
index b1ef27eccc8397083c68f4729eb1a8935bb336e3..d5de650b7025afc88c4fa7f7b19ba8ca9b1fcaf3 100644 (file)
@@ -11,7 +11,7 @@
  * See the sre.c file for information on usage and redistribution.
  */
 
-#define SRE_MAGIC 20220402
+#define SRE_MAGIC 20220423
 #define SRE_OP_FAILURE 0
 #define SRE_OP_SUCCESS 1
 #define SRE_OP_ANY 2
 #define SRE_OP_ASSERT_NOT 5
 #define SRE_OP_AT 6
 #define SRE_OP_BRANCH 7
-#define SRE_OP_CALL 8
-#define SRE_OP_CATEGORY 9
-#define SRE_OP_CHARSET 10
-#define SRE_OP_BIGCHARSET 11
-#define SRE_OP_GROUPREF 12
-#define SRE_OP_GROUPREF_EXISTS 13
-#define SRE_OP_IN 14
-#define SRE_OP_INFO 15
-#define SRE_OP_JUMP 16
-#define SRE_OP_LITERAL 17
-#define SRE_OP_MARK 18
-#define SRE_OP_MAX_UNTIL 19
-#define SRE_OP_MIN_UNTIL 20
-#define SRE_OP_NOT_LITERAL 21
-#define SRE_OP_NEGATE 22
-#define SRE_OP_RANGE 23
-#define SRE_OP_REPEAT 24
-#define SRE_OP_REPEAT_ONE 25
-#define SRE_OP_SUBPATTERN 26
-#define SRE_OP_MIN_REPEAT_ONE 27
-#define SRE_OP_ATOMIC_GROUP 28
-#define SRE_OP_POSSESSIVE_REPEAT 29
-#define SRE_OP_POSSESSIVE_REPEAT_ONE 30
-#define SRE_OP_GROUPREF_IGNORE 31
-#define SRE_OP_IN_IGNORE 32
-#define SRE_OP_LITERAL_IGNORE 33
-#define SRE_OP_NOT_LITERAL_IGNORE 34
-#define SRE_OP_GROUPREF_LOC_IGNORE 35
-#define SRE_OP_IN_LOC_IGNORE 36
-#define SRE_OP_LITERAL_LOC_IGNORE 37
-#define SRE_OP_NOT_LITERAL_LOC_IGNORE 38
-#define SRE_OP_GROUPREF_UNI_IGNORE 39
-#define SRE_OP_IN_UNI_IGNORE 40
-#define SRE_OP_LITERAL_UNI_IGNORE 41
-#define SRE_OP_NOT_LITERAL_UNI_IGNORE 42
-#define SRE_OP_RANGE_UNI_IGNORE 43
+#define SRE_OP_CATEGORY 8
+#define SRE_OP_CHARSET 9
+#define SRE_OP_BIGCHARSET 10
+#define SRE_OP_GROUPREF 11
+#define SRE_OP_GROUPREF_EXISTS 12
+#define SRE_OP_IN 13
+#define SRE_OP_INFO 14
+#define SRE_OP_JUMP 15
+#define SRE_OP_LITERAL 16
+#define SRE_OP_MARK 17
+#define SRE_OP_MAX_UNTIL 18
+#define SRE_OP_MIN_UNTIL 19
+#define SRE_OP_NOT_LITERAL 20
+#define SRE_OP_NEGATE 21
+#define SRE_OP_RANGE 22
+#define SRE_OP_REPEAT 23
+#define SRE_OP_REPEAT_ONE 24
+#define SRE_OP_SUBPATTERN 25
+#define SRE_OP_MIN_REPEAT_ONE 26
+#define SRE_OP_ATOMIC_GROUP 27
+#define SRE_OP_POSSESSIVE_REPEAT 28
+#define SRE_OP_POSSESSIVE_REPEAT_ONE 29
+#define SRE_OP_GROUPREF_IGNORE 30
+#define SRE_OP_IN_IGNORE 31
+#define SRE_OP_LITERAL_IGNORE 32
+#define SRE_OP_NOT_LITERAL_IGNORE 33
+#define SRE_OP_GROUPREF_LOC_IGNORE 34
+#define SRE_OP_IN_LOC_IGNORE 35
+#define SRE_OP_LITERAL_LOC_IGNORE 36
+#define SRE_OP_NOT_LITERAL_LOC_IGNORE 37
+#define SRE_OP_GROUPREF_UNI_IGNORE 38
+#define SRE_OP_IN_UNI_IGNORE 39
+#define SRE_OP_LITERAL_UNI_IGNORE 40
+#define SRE_OP_NOT_LITERAL_UNI_IGNORE 41
+#define SRE_OP_RANGE_UNI_IGNORE 42
 #define SRE_AT_BEGINNING 0
 #define SRE_AT_BEGINNING_LINE 1
 #define SRE_AT_BEGINNING_STRING 2
index efd6fdeccce3f2ecbca0a5d41d4aed0a5d69132b..1e5b50170ae76ed75ab53e1533c8ef01b0f9edde 100644 (file)
@@ -1547,7 +1547,6 @@ dispatch:
         TARGET(SRE_OP_NEGATE):
         TARGET(SRE_OP_BIGCHARSET):
         TARGET(SRE_OP_CHARSET):
-        TARGET(SRE_OP_CALL):
             TRACE(("|%p|%p|UNKNOWN %d\n", pattern, ptr,
                    pattern[-1]));
             RETURN_ERROR(SRE_ERROR_ILLEGAL);
index 389e7d77e949c14212a0e95b8ecdb4508e659350..25b6edd436bb7349ee0accc94b62fd0ba1fc908b 100644 (file)
@@ -11,7 +11,7 @@
  * See the sre.c file for information on usage and redistribution.
  */
 
-static void *sre_targets[44] = {
+static void *sre_targets[43] = {
     &&TARGET_SRE_OP_FAILURE,
     &&TARGET_SRE_OP_SUCCESS,
     &&TARGET_SRE_OP_ANY,
@@ -20,7 +20,6 @@ static void *sre_targets[44] = {
     &&TARGET_SRE_OP_ASSERT_NOT,
     &&TARGET_SRE_OP_AT,
     &&TARGET_SRE_OP_BRANCH,
-    &&TARGET_SRE_OP_CALL,
     &&TARGET_SRE_OP_CATEGORY,
     &&TARGET_SRE_OP_CHARSET,
     &&TARGET_SRE_OP_BIGCHARSET,