diff options
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 2ee71bb..241281e 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -245,10 +245,9 @@ bytes_contains(PyBytesObject *self, PyObject *value) if (PyBytes_Check(value)) return bytes_substring(self, (PyBytesObject *)value); - ival = PyNumber_Index(value); + ival = PyNumber_AsSsize_t(value, PyExc_TypeError); if (ival == -1 && PyErr_Occurred()) return -1; - if (ival < 0 || ival >= 256) { PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); return -1; @@ -366,7 +365,7 @@ bytes_setitem(PyBytesObject *self, Py_ssize_t i, PyObject *value) if (value == NULL) return bytes_setslice(self, i, i+1, NULL); - ival = PyNumber_Index(value); + ival = PyNumber_AsSsize_t(value, PyExc_TypeError); if (ival == -1 && PyErr_Occurred()) return -1; @@ -449,7 +448,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) } /* Is it an int? */ - count = PyNumber_Index(arg); + count = PyNumber_AsSsize_t(arg, PyExc_TypeError); if (count == -1 && PyErr_Occurred()) PyErr_Clear(); else { @@ -501,7 +500,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) } /* Interpret it as an int (__index__) */ - value = PyNumber_Index(item); + value = PyNumber_AsSsize_t(item, PyExc_TypeError); Py_DECREF(item); if (value == -1 && PyErr_Occurred()) goto error; |