summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-22 08:30:14 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-22 08:30:14 (GMT)
commit53d2dc4045f6793d166b2806d7726c45cdea74e4 (patch)
treefa105ed32a04c595ddf311dd81ee400ff5535f5f /Parser
parent43d82df406114223c70961f0774d622536a0629d (diff)
downloadcpython-53d2dc4045f6793d166b2806d7726c45cdea74e4.zip
cpython-53d2dc4045f6793d166b2806d7726c45cdea74e4.tar.gz
cpython-53d2dc4045f6793d166b2806d7726c45cdea74e4.tar.bz2
Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when debugging
a new grammar. CID 715360
Diffstat (limited to 'Parser')
-rw-r--r--Parser/grammar1.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Parser/grammar1.c b/Parser/grammar1.c
index 1f7d264..17e2ba9 100644
--- a/Parser/grammar1.c
+++ b/Parser/grammar1.c
@@ -45,7 +45,7 @@ PyGrammar_LabelRepr(label *lb)
else
return lb->lb_str;
}
- else {
+ else if (lb->lb_type < N_TOKENS) {
if (lb->lb_str == NULL)
return _PyParser_TokenNames[lb->lb_type];
else {
@@ -54,4 +54,7 @@ PyGrammar_LabelRepr(label *lb)
return buf;
}
}
+ else {
+ Py_FatalError("invalid label");
+ }
}