From 6bf9b2ad67cc18be8ea7a5eb6c36d0bc76d47ab8 Mon Sep 17 00:00:00 2001 From: soummyaah Date: Mon, 19 Sep 2016 13:42:28 +0530 Subject: [PATCH] patch to issue 28203 --- Objects/complexobject.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Objects/complexobject.c b/Objects/complexobject.c index a9d5ec3..9afd745 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -967,8 +967,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) nbr = r->ob_type->tp_as_number; if (i != NULL) nbi = i->ob_type->tp_as_number; - if (nbr == NULL || nbr->nb_float == NULL || - ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { + if (nbr == NULL || nbr->nb_float == NULL) { PyErr_Format(PyExc_TypeError, "complex() argument must be a string or a number, not '%.200s'", Py_TYPE(r)->tp_name); @@ -977,6 +976,15 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } return NULL; } + if (i != NULL && (nbi == NULL || nbi->nb_float == NULL)) { + PyErr_Format(PyExc_TypeError, + "complex() argument must be a string or a number, not '%.200s'", + Py_TYPE(i)->tp_name); + if (own_r) { + Py_DECREF(r); + } + return NULL; + } /* If we get this far, then the "real" and "imag" parts should both be treated as numbers, and the constructor should return a -- 2.5.0