Skip to content

Commit 14f3574

Browse files
committed
gh-159672: Declare keyword aliases as immutable data
Use a named alias type with constant pointer fields so the alias table is explicitly immutable.
1 parent 3343af0 commit 14f3574

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎Parser/pegen.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,11 @@ typedef struct {
10861086
int is_alias;
10871087
} KeywordTypo;
10881088

1089+
typedef struct {
1090+
const char * const name;
1091+
const char * const keyword;
1092+
} KeywordAlias;
1093+
10891094
#define MAX_KEYWORD_TYPO_CANDIDATES 32
10901095
#define MAX_KEYWORD_TYPO_STEPS 5000000
10911096

@@ -1307,7 +1312,7 @@ collect_keyword_typos(Parser *p, PySyntaxErrorObject *error, KeywordTypo *candid
13071312
start = i + 1;
13081313
}
13091314
}
1310-
static const struct { const char *name, *keyword; } aliases[] = {
1315+
static const KeywordAlias aliases[] = {
13111316
{"switch", "match"},
13121317
{"delete", "del"},
13131318
{"function", "def"},

0 commit comments

Comments
 (0)