From 5cd62b7fe17e8004a4f137cf9164e4e71bb1bd70 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 25 Nov 2012 14:36:26 +0000 Subject: Issue #16546: make ast.YieldFrom argument mandatory. --- Python/Python-ast.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Python/Python-ast.c') diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 805f2b8af1..e6f1e58252 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -1802,6 +1802,11 @@ expr_ty YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena) { expr_ty p; + if (!value) { + PyErr_SetString(PyExc_ValueError, + "field value is required for YieldFrom"); + return NULL; + } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) return NULL; @@ -5431,7 +5436,8 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) Py_XDECREF(tmp); tmp = NULL; } else { - value = NULL; + PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom"); + return 1; } *out = YieldFrom(value, lineno, col_offset, arena); if (*out == NULL) goto failed; -- cgit v1.2.1