From 813f943c592cf225871b99cffc99304c8cbbee40 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 16 Apr 2017 09:21:44 +0300 Subject: bpo-29838: Add asserts for checking results of sq_length and mq_length slots. (#700) Negative result should be returned only when an error is set. --- Python/bltinmodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 8ae2303e98..60d1b7cf92 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1479,8 +1479,10 @@ builtin_len(PyObject *module, PyObject *obj) Py_ssize_t res; res = PyObject_Size(obj); - if (res < 0 && PyErr_Occurred()) + if (res < 0) { + assert(PyErr_Occurred()); return NULL; + } return PyLong_FromSsize_t(res); } -- cgit v1.2.1