| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -328,6 +328,14 @@ def split_zeros(x): | |||
| 328 | 328 | self.assertRaises(ValueError, complex, "1e1ej") | |
| 329 | 329 | self.assertRaises(ValueError, complex, "1e++1ej") | |
| 330 | 330 | self.assertRaises(ValueError, complex, ")1+2j(") | |
| 331 | + self.assertRaisesRegex( | ||
| 332 | + TypeError, | ||
| 333 | + "first argument must be a string or a number, not 'dict'", | ||
| 334 | + complex, {1:2}, 1) | ||
| 335 | + self.assertRaisesRegex( | ||
| 336 | + TypeError, | ||
| 337 | + "second argument must be a number, not 'dict'", | ||
| 338 | + complex, 1, {1:2}) | ||
| 331 | 339 | # the following three are accepted by Python 2.6 | |
| 332 | 340 | self.assertRaises(ValueError, complex, "1..1j") | |
| 333 | 341 | self.assertRaises(ValueError, complex, "1.11.1j") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1369,6 +1369,7 @@ Daniel Shahaf | |||
| 1369 | 1369 | Mark Shannon | |
| 1370 | 1370 | Ha Shao | |
| 1371 | 1371 | Richard Shapiro | |
| 1372 | + Soumya Sharma | ||
| 1372 | 1373 | Varun Sharma | |
| 1373 | 1374 | Daniel Shaulov | |
| 1374 | 1375 | Vlad Shcherbina | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 2 | |||
| 10 | 10 | Core and Builtins | |
| 11 | 11 | ----------------- | |
| 12 | 12 | ||
| 13 | + - Issue #28203: Fix incorrect type in complex(1.0, {2:3}) error message. | ||
| 14 | + Patch by Soumya Sharma. | ||
| 15 | + | ||
| 13 | 16 | - Issue #28086: Single var-positional argument of tuple subtype was passed | |
| 14 | 17 | unscathed to the C-defined function. Now it is converted to exact tuple. | |
| 15 | 18 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -965,18 +965,29 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |||
| 965 | 965 | } | |
| 966 | 966 | ||
| 967 | 967 | nbr = r->ob_type->tp_as_number; | |
| 968 | - if (i != NULL) | ||
| 969 | - nbi = i->ob_type->tp_as_number; | ||
| 970 | - if (nbr == NULL || nbr->nb_float == NULL || | ||
| 971 | - ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { | ||
| 968 | + if (nbr == NULL || nbr->nb_float == NULL) { | ||
| 972 | 969 | PyErr_Format(PyExc_TypeError, | |
| 973 | - "complex() argument must be a string or a number, not '%.200s'", | ||
| 974 | - Py_TYPE(r)->tp_name); | ||
| 970 | + "complex() first argument must be a string or a number, " | ||
| 971 | + "not '%.200s'", | ||
| 972 | + Py_TYPE(r)->tp_name); | ||
| 975 | 973 | if (own_r) { | |
| 976 | 974 | Py_DECREF(r); | |
| 977 | 975 | } | |
| 978 | 976 | return NULL; | |
| 979 | 977 | } | |
| 978 | + if (i != NULL) { | ||
| 979 | + nbi = i->ob_type->tp_as_number; | ||
| 980 | + if (nbi == NULL || nbi->nb_float == NULL) { | ||
| 981 | + PyErr_Format(PyExc_TypeError, | ||
| 982 | + "complex() second argument must be a number, " | ||
| 983 | + "not '%.200s'", | ||
| 984 | + Py_TYPE(i)->tp_name); | ||
| 985 | + if (own_r) { | ||
| 986 | + Py_DECREF(r); | ||
| 987 | + } | ||
| 988 | + return NULL; | ||
| 989 | + } | ||
| 990 | + } | ||
| 980 | 991 | ||
| 981 | 992 | /* If we get this far, then the "real" and "imag" parts should | |
| 982 | 993 | both be treated as numbers, and the constructor should return a | |
| Back | FazBrowse Home | New Git URL |
0 commit comments