This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients josh.r, mark.dickinson, tim.peters
Date 2014-04-10.13:49:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397137769.09.0.734022054294.issue21193@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-04-10 13:49:29mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, josh.r
2014-04-10 13:49:29mark.dickinsonsetmessageid: <1397137769.09.0.734022054294.issue21193@psf.upfronthosting.co.za>
2014-04-10 13:49:29mark.dickinsonlinkissue21193 messages
2014-04-10 13:49:28mark.dickinsoncreate