diff options
author | 2013-11-07 19:18:34 +0200 | |
---|---|---|
committer | 2013-11-07 19:18:34 +0200 | |
commit | a5b9599538083468cffee3c052e15dd541c4bbd5 (patch) | |
tree | 62ec19c7e876881fccd49e0eada11c08ea461806 /Objects/complexobject.c | |
parent | Optimize BaseSelector.modify(). Patch by Arnaud Faure. (diff) | |
download | cpython-a5b9599538083468cffee3c052e15dd541c4bbd5.tar.gz cpython-a5b9599538083468cffee3c052e15dd541c4bbd5.tar.bz2 cpython-a5b9599538083468cffee3c052e15dd541c4bbd5.zip |
#17080: improve error message of float/complex when the wrong type is passed.
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r-- | Objects/complexobject.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 64e7b445777..60a388fa241 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -773,8 +773,9 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) goto error; } else if (PyObject_AsCharBuffer(v, &s, &len)) { - PyErr_SetString(PyExc_TypeError, - "complex() argument must be a string or a number"); + PyErr_Format(PyExc_TypeError, + "complex() argument must be a string or a number, not '%.200s'", + Py_TYPE(v)->tp_name); return NULL; } @@ -953,8 +954,9 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) nbi = i->ob_type->tp_as_number; if (nbr == NULL || nbr->nb_float == NULL || ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { - PyErr_SetString(PyExc_TypeError, - "complex() argument must be a string or a number"); + PyErr_Format(PyExc_TypeError, + "complex() argument must be a string or a number, not '%.200s'", + Py_TYPE(r)->tp_name); if (own_r) { Py_DECREF(r); } |