Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 817d6c9

Browse files
committed
Prompted by Tim's comment, when handle_range_longs() sees an
unexpected type, report the actual type rather than 'float'. (It's hard to even reach this code with a float. :-)
1 parent 41c99e7 commit 817d6c9

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Python/bltinmodule.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,24 +1366,24 @@ handle_range_longs(PyObject *self, PyObject *args)
13661366
Py_INCREF(istep);
13671367
}
13681368

1369-
/* XXX What reason do we have to believe that if an arg isn't an
1370-
* XXX int, it must be a float?
1371-
*/
13721369
if (!PyInt_Check(ilow) && !PyLong_Check(ilow)) {
1373-
PyErr_SetString(PyExc_ValueError,
1374-
"integer start argument expected, got float.");
1370+
PyErr_Format(PyExc_ValueError,
1371+
"integer start argument expected, got %s.",
1372+
ilow->ob_type->tp_name);
13751373
goto Fail;
13761374
}
13771375

13781376
if (!PyInt_Check(ihigh) && !PyLong_Check(ihigh)) {
1379-
PyErr_SetString(PyExc_ValueError,
1380-
"integer end argument expected, got float.");
1377+
PyErr_Format(PyExc_ValueError,
1378+
"integer end argument expected, got %s.",
1379+
ihigh->ob_type->tp_name);
13811380
goto Fail;
13821381
}
13831382

13841383
if (!PyInt_Check(istep) && !PyLong_Check(istep)) {
1385-
PyErr_SetString(PyExc_ValueError,
1386-
"integer step argument expected, got float.");
1384+
PyErr_Format(PyExc_ValueError,
1385+
"integer step argument expected, got %s.",
1386+
istep->ob_type->tp_name);
13871387
goto Fail;
13881388
}
13891389

0 commit comments

Comments
 (0)