Skip to content

Commit 2497054

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 c3621d5 commit 2497054

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
@@ -1085,6 +1085,11 @@ typedef struct {
10851085
int is_alias;
10861086
} KeywordTypo;
10871087

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

@@ -1306,7 +1311,7 @@ collect_keyword_typos(Parser *p, PySyntaxErrorObject *error, KeywordTypo *candid
13061311
start = i + 1;
13071312
}
13081313
}
1309-
static const struct { const char *name, *keyword; } aliases[] = {
1314+
static const KeywordAlias aliases[] = {
13101315
{"switch", "match"},
13111316
{"delete", "del"},
13121317
{"function", "def"},

0 commit comments

Comments
 (0)