mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	Add sanity check to PyGrammar_LabelRepr() in order to catch invalid tokens when debugging
a new grammar. CID 715360
This commit is contained in:
		
							parent
							
								
									43d82df406
								
							
						
					
					
						commit
						53d2dc4045
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -45,7 +45,7 @@ PyGrammar_LabelRepr(label *lb)
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            return lb->lb_str;
 | 
					            return lb->lb_str;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else if (lb->lb_type < N_TOKENS) {
 | 
				
			||||||
        if (lb->lb_str == NULL)
 | 
					        if (lb->lb_str == NULL)
 | 
				
			||||||
            return _PyParser_TokenNames[lb->lb_type];
 | 
					            return _PyParser_TokenNames[lb->lb_type];
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
| 
						 | 
					@ -54,4 +54,7 @@ PyGrammar_LabelRepr(label *lb)
 | 
				
			||||||
            return buf;
 | 
					            return buf;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        Py_FatalError("invalid label");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue