FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.9] bpo-41215: Don't use NULL by default in the PEG parser keyword list (GH-21355) by pablogsal · Pull Request #21356 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use non-NULL default values in the PEG parser keyword list to overcome a bug that was preventing
Python from being properly compiled when using the XLC compiler. Patch by Pablo Galindo.
14 changes: 7 additions & 7 deletions Parser/pegen/parse.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ extern int Py_DebugFlag;
#endif
static const int n_keyword_lists = 15;
static KeywordToken *reserved_keywords[] = {
NULL,
NULL,
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {
{"if", 510},
{"in", 518},
Expand Down Expand Up @@ -65,11 +65,11 @@ static KeywordToken *reserved_keywords[] = {
{"nonlocal", 509},
{NULL, -1},
},
NULL,
NULL,
NULL,
NULL,
NULL,
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {
{"__peg_parser__", 531},
{NULL, -1},
Expand Down
7 changes: 5 additions & 2 deletions Parser/pegen/pegen.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,13 @@ _PyPegen_dummy_name(Parser *p, ...)
static int
_get_keyword_or_name_type(Parser *p, const char *name, int name_len)
{
if (name_len >= p->n_keyword_lists || p->keywords[name_len] == NULL) {
assert(name_len != 0);
if (name_len >= p->n_keyword_lists ||
p->keywords[name_len] == NULL ||
p->keywords[name_len]->type == -1) {
return NAME;
}
for (KeywordToken *k = p->keywords[name_len]; k->type != -1; k++) {
for (KeywordToken *k = p->keywords[name_len]; k != NULL && k->type != -1; k++) {
if (strncmp(k->str, name, name_len) == 0) {
return k->type;
}
Expand Down
2 changes: 1 addition & 1 deletion Tools/peg_generator/pegen/c_generator.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def _setup_keywords(self) -> None:
num_groups = max(groups) + 1 if groups else 1
for keywords_length in range(num_groups):
if keywords_length not in groups.keys():
self.print("NULL,")
self.print("(KeywordToken[]) {{NULL, -1}},")
else:
self.print("(KeywordToken[]) {")
with self.indent():
Expand Down

Back | FazBrowse Home | New Git URL