From c381f246d20a4edd6343beef5ccc34163d55c910 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Fri, 30 Oct 2020 13:11:37 +0300 Subject: [PATCH] bpo-42206: Propagate and raise errors from PyAST_Validate in the parser --- .../2020-10-30-13-11-01.bpo-42206.xxssR8.rst | 2 ++ Parser/pegen.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst new file mode 100644 index 00000000000000..b9eb135fec5e9c --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst @@ -0,0 +1,2 @@ +Propagate and raise the errors caused by :c:func:`PyAST_Validate` in the +parser. diff --git a/Parser/pegen.c b/Parser/pegen.c index efa5ed9f288ee0..ea7e307c678c5f 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -1143,7 +1143,9 @@ _PyPegen_run_parser(Parser *p) p->start_rule == Py_file_input || p->start_rule == Py_eval_input) { - assert(PyAST_Validate(res)); + if (!PyAST_Validate(res)) { + return NULL; + } } #endif return res;