Message215882
I was wondering how the TypeError got there in the first place. Diving into the history is instructive: changeset cdfdd5359411 modified the exception message:
taniyama:cpython mdickinson$ hg log -r19719
changeset: 19719:cdfdd5359411
branch: legacy-trunk
user: Tim Peters <tim.peters@gmail.com>
date: Wed Sep 05 06:24:58 2001 +0000
summary: Make the error msgs in our pow() implementations consistent.
Before that change, the code looked like this:
if (x != Py_None) {
PyErr_SetString(PyExc_TypeError, "integer pow() arg "
"3 must not be specified when arg 2 is < 0");
return NULL;
}
From that point of view the TypeError makes more sense: it's complaining about the wrong number of arguments rather than the negative value. The current message changes the perspective, and I agree that ValueError makes more sense.
Tim: any objections to changing the exception type from TypeError to ValueError for Python 3.5?
I'd prefer not to change it for 2.7 or 3.4: there's an (admittedly probably quite low) risk of code breakage, and little real gain to offset that breakage. |
|
Date |
User |
Action |
Args |
2014-04-10 13:49:29 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, josh.r |
2014-04-10 13:49:29 | mark.dickinson | set | messageid: <1397137769.09.0.734022054294.issue21193@psf.upfronthosting.co.za> |
2014-04-10 13:49:29 | mark.dickinson | link | issue21193 messages |
2014-04-10 13:49:28 | mark.dickinson | create | |
|