Skip to content

Commit f703c96

Browse files
gh-91870: Remove unsupported SRE opcode CALL (GH-91872)
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.
1 parent 1af871e commit f703c96

File tree

6 files changed

+38
-52
lines changed

6 files changed

+38
-52
lines changed

Lib/re/_compiler.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,6 @@ def _compile(data, pattern, flags):
164164
_compile(data, av[1], flags)
165165
emit(SUCCESS)
166166
code[skip] = _len(code) - skip
167-
elif op is CALL:
168-
emit(op)
169-
skip = _len(code); emit(0)
170-
_compile(data, av, flags)
171-
emit(SUCCESS)
172-
code[skip] = _len(code) - skip
173167
elif op is AT:
174168
emit(op)
175169
if flags & SRE_FLAG_MULTILINE:

Lib/re/_constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# update when constants are added or removed
1515

16-
MAGIC = 20220402
16+
MAGIC = 20220423
1717

1818
from _sre import MAXREPEAT, MAXGROUPS
1919

@@ -78,7 +78,6 @@ def _makecodes(*names):
7878
'ASSERT', 'ASSERT_NOT',
7979
'AT',
8080
'BRANCH',
81-
'CALL',
8281
'CATEGORY',
8382
'CHARSET', 'BIGCHARSET',
8483
'GROUPREF', 'GROUPREF_EXISTS',

Lib/re/_parser.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ def getwidth(self):
183183
j = max(j, h)
184184
lo = lo + i
185185
hi = hi + j
186-
elif op is CALL:
187-
i, j = av.getwidth()
188-
lo = lo + i
189-
hi = hi + j
190186
elif op is ATOMIC_GROUP:
191187
i, j = av.getwidth()
192188
lo = lo + i

Modules/_sre/sre_constants.h

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the sre.c file for information on usage and redistribution.
1212
*/
1313

14-
#define SRE_MAGIC 20220402
14+
#define SRE_MAGIC 20220423
1515
#define SRE_OP_FAILURE 0
1616
#define SRE_OP_SUCCESS 1
1717
#define SRE_OP_ANY 2
@@ -20,42 +20,41 @@
2020
#define SRE_OP_ASSERT_NOT 5
2121
#define SRE_OP_AT 6
2222
#define SRE_OP_BRANCH 7
23-
#define SRE_OP_CALL 8
24-
#define SRE_OP_CATEGORY 9
25-
#define SRE_OP_CHARSET 10
26-
#define SRE_OP_BIGCHARSET 11
27-
#define SRE_OP_GROUPREF 12
28-
#define SRE_OP_GROUPREF_EXISTS 13
29-
#define SRE_OP_IN 14
30-
#define SRE_OP_INFO 15
31-
#define SRE_OP_JUMP 16
32-
#define SRE_OP_LITERAL 17
33-
#define SRE_OP_MARK 18
34-
#define SRE_OP_MAX_UNTIL 19
35-
#define SRE_OP_MIN_UNTIL 20
36-
#define SRE_OP_NOT_LITERAL 21
37-
#define SRE_OP_NEGATE 22
38-
#define SRE_OP_RANGE 23
39-
#define SRE_OP_REPEAT 24
40-
#define SRE_OP_REPEAT_ONE 25
41-
#define SRE_OP_SUBPATTERN 26
42-
#define SRE_OP_MIN_REPEAT_ONE 27
43-
#define SRE_OP_ATOMIC_GROUP 28
44-
#define SRE_OP_POSSESSIVE_REPEAT 29
45-
#define SRE_OP_POSSESSIVE_REPEAT_ONE 30
46-
#define SRE_OP_GROUPREF_IGNORE 31
47-
#define SRE_OP_IN_IGNORE 32
48-
#define SRE_OP_LITERAL_IGNORE 33
49-
#define SRE_OP_NOT_LITERAL_IGNORE 34
50-
#define SRE_OP_GROUPREF_LOC_IGNORE 35
51-
#define SRE_OP_IN_LOC_IGNORE 36
52-
#define SRE_OP_LITERAL_LOC_IGNORE 37
53-
#define SRE_OP_NOT_LITERAL_LOC_IGNORE 38
54-
#define SRE_OP_GROUPREF_UNI_IGNORE 39
55-
#define SRE_OP_IN_UNI_IGNORE 40
56-
#define SRE_OP_LITERAL_UNI_IGNORE 41
57-
#define SRE_OP_NOT_LITERAL_UNI_IGNORE 42
58-
#define SRE_OP_RANGE_UNI_IGNORE 43
23+
#define SRE_OP_CATEGORY 8
24+
#define SRE_OP_CHARSET 9
25+
#define SRE_OP_BIGCHARSET 10
26+
#define SRE_OP_GROUPREF 11
27+
#define SRE_OP_GROUPREF_EXISTS 12
28+
#define SRE_OP_IN 13
29+
#define SRE_OP_INFO 14
30+
#define SRE_OP_JUMP 15
31+
#define SRE_OP_LITERAL 16
32+
#define SRE_OP_MARK 17
33+
#define SRE_OP_MAX_UNTIL 18
34+
#define SRE_OP_MIN_UNTIL 19
35+
#define SRE_OP_NOT_LITERAL 20
36+
#define SRE_OP_NEGATE 21
37+
#define SRE_OP_RANGE 22
38+
#define SRE_OP_REPEAT 23
39+
#define SRE_OP_REPEAT_ONE 24
40+
#define SRE_OP_SUBPATTERN 25
41+
#define SRE_OP_MIN_REPEAT_ONE 26
42+
#define SRE_OP_ATOMIC_GROUP 27
43+
#define SRE_OP_POSSESSIVE_REPEAT 28
44+
#define SRE_OP_POSSESSIVE_REPEAT_ONE 29
45+
#define SRE_OP_GROUPREF_IGNORE 30
46+
#define SRE_OP_IN_IGNORE 31
47+
#define SRE_OP_LITERAL_IGNORE 32
48+
#define SRE_OP_NOT_LITERAL_IGNORE 33
49+
#define SRE_OP_GROUPREF_LOC_IGNORE 34
50+
#define SRE_OP_IN_LOC_IGNORE 35
51+
#define SRE_OP_LITERAL_LOC_IGNORE 36
52+
#define SRE_OP_NOT_LITERAL_LOC_IGNORE 37
53+
#define SRE_OP_GROUPREF_UNI_IGNORE 38
54+
#define SRE_OP_IN_UNI_IGNORE 39
55+
#define SRE_OP_LITERAL_UNI_IGNORE 40
56+
#define SRE_OP_NOT_LITERAL_UNI_IGNORE 41
57+
#define SRE_OP_RANGE_UNI_IGNORE 42
5958
#define SRE_AT_BEGINNING 0
6059
#define SRE_AT_BEGINNING_LINE 1
6160
#define SRE_AT_BEGINNING_STRING 2

Modules/_sre/sre_lib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,6 @@ SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel)
15471547
TARGET(SRE_OP_NEGATE):
15481548
TARGET(SRE_OP_BIGCHARSET):
15491549
TARGET(SRE_OP_CHARSET):
1550-
TARGET(SRE_OP_CALL):
15511550
TRACE(("|%p|%p|UNKNOWN %d\n", pattern, ptr,
15521551
pattern[-1]));
15531552
RETURN_ERROR(SRE_ERROR_ILLEGAL);

Modules/_sre/sre_targets.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the sre.c file for information on usage and redistribution.
1212
*/
1313

14-
static void *sre_targets[44] = {
14+
static void *sre_targets[43] = {
1515
&&TARGET_SRE_OP_FAILURE,
1616
&&TARGET_SRE_OP_SUCCESS,
1717
&&TARGET_SRE_OP_ANY,
@@ -20,7 +20,6 @@ static void *sre_targets[44] = {
2020
&&TARGET_SRE_OP_ASSERT_NOT,
2121
&&TARGET_SRE_OP_AT,
2222
&&TARGET_SRE_OP_BRANCH,
23-
&&TARGET_SRE_OP_CALL,
2423
&&TARGET_SRE_OP_CATEGORY,
2524
&&TARGET_SRE_OP_CHARSET,
2625
&&TARGET_SRE_OP_BIGCHARSET,

0 commit comments

Comments
 (0)