mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity. This (mostly) closes SourceForge patch #101839.
This commit is contained in:
parent
bd6f4fba1b
commit
661ea26b3d
16 changed files with 186 additions and 144 deletions
|
@ -171,7 +171,7 @@ PyInt_FromString(char *s, char **pend, int base)
|
|||
char buffer[256]; /* For errors */
|
||||
|
||||
if ((base != 0 && base < 2) || base > 36) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid base for int()");
|
||||
PyErr_SetString(PyExc_ValueError, "int() base must be >= 2 and <= 36");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ i_divmod(register PyIntObject *x, register PyIntObject *y,
|
|||
|
||||
if (yi == 0) {
|
||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||
"integer division or modulo");
|
||||
"integer division or modulo by zero");
|
||||
return -1;
|
||||
}
|
||||
if (yi < 0) {
|
||||
|
@ -485,17 +485,17 @@ int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z)
|
|||
if (iw < 0) {
|
||||
if (iv)
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"integer to a negative power");
|
||||
"cannot raise integer to a negative power");
|
||||
else
|
||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||
"0 to a negative power");
|
||||
"cannot raise 0 to a negative power");
|
||||
return NULL;
|
||||
}
|
||||
if ((PyObject *)z != Py_None) {
|
||||
iz = z->ob_ival;
|
||||
if (iz == 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"pow(x, y, z) with z==0");
|
||||
"pow() arg 3 cannot be 0");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue