diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/tupleobject.c | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index f7b316b..8828a2d 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -458,7 +458,7 @@ tupleindex(PyTupleObject *self, PyObject *args) else if (cmp < 0) return NULL; } - PyErr_SetString(PyExc_ValueError, "tuple.index(x): x not in list"); + PyErr_SetString(PyExc_ValueError, "tuple.index(x): x not in tuple"); return NULL; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index a362b84..47bc0bb 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4785,7 +4785,7 @@ slot_nb_bool(PyObject *self) PyObject *func, *args; static PyObject *bool_str, *len_str; int result = -1; - int from_len = 0; + int using_len = 0; func = lookup_maybe(self, "__bool__", &bool_str); if (func == NULL) { @@ -4794,14 +4794,14 @@ slot_nb_bool(PyObject *self) func = lookup_maybe(self, "__len__", &len_str); if (func == NULL) return PyErr_Occurred() ? -1 : 1; - from_len = 1; - } + using_len = 1; + } args = PyTuple_New(0); if (args != NULL) { PyObject *temp = PyObject_Call(func, args, NULL); Py_DECREF(args); if (temp != NULL) { - if (from_len) { + if (using_len) { /* enforced by slot_nb_len */ result = PyObject_IsTrue(temp); } @@ -4810,9 +4810,11 @@ slot_nb_bool(PyObject *self) } else { PyErr_Format(PyExc_TypeError, - "__bool__ should return " - "bool, returned %s", - Py_TYPE(temp)->tp_name); + "%s should return " + "bool or int, returned %s", + (using_len ? "__len__" + : "__bool__"), + Py_TYPE(temp)->tp_name); result = -1; } Py_DECREF(temp); |