bpo-40904: Fix segfault in the new parser with f-string containing yield statements with no value (GH-20701)
(cherry picked from commit 972ab0327675e695373fc6272d5ac24e187579ad)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
diff --git a/Parser/pegen/parse_string.c b/Parser/pegen/parse_string.c
index efe82df..94241e1 100644
--- a/Parser/pegen/parse_string.c
+++ b/Parser/pegen/parse_string.c
@@ -278,6 +278,9 @@
static inline void shift_expr(expr_ty parent, expr_ty n, int line, int col) {
+ if (n == NULL) {
+ return;
+ }
if (parent->lineno < n->lineno) {
col = 0;
}