[Python-checkins] cpython (3.3): Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when

christian.heimes python-checkins at python.org
Mon Jul 22 10:38:16 CEST 2013


http://hg.python.org/cpython/rev/03b937e5b19f
changeset:   84781:03b937e5b19f
branch:      3.3
parent:      84770:82706297973b
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Jul 22 10:30:14 2013 +0200
summary:
  Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when debugging
a new grammar.
CID 715360

files:
  Parser/grammar1.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Parser/grammar1.c b/Parser/grammar1.c
--- a/Parser/grammar1.c
+++ b/Parser/grammar1.c
@@ -45,7 +45,7 @@
         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 @@
             return buf;
         }
     }
+    else {
+        Py_FatalError("invalid label");
+    }
 }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list