diff options
Diffstat (limited to 'Modules/_io/bytesio.c')
-rw-r--r-- | Modules/_io/bytesio.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index 0a0e5e7..59b917d 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -578,12 +578,18 @@ _io_BytesIO_truncate_impl(bytesio *self, PyObject *arg) /* Truncate to current position if no argument is passed. */ size = self->pos; } - else { + else if (PyIndex_Check(arg)) { size = PyNumber_AsSsize_t(arg, PyExc_OverflowError); if (size == -1 && PyErr_Occurred()) { return NULL; } } + else { + PyErr_Format(PyExc_TypeError, + "argument should be integer or None, not '%.200s'", + Py_TYPE(arg)->tp_name); + return NULL; + } if (size < 0) { PyErr_Format(PyExc_ValueError, |