[Python-checkins] r60835 - python/trunk/Objects/abstract.c

eric.smith python-checkins at python.org
Fri Feb 15 13:14:32 CET 2008


Author: eric.smith
Date: Fri Feb 15 13:14:32 2008
New Revision: 60835

Modified:
   python/trunk/Objects/abstract.c
Log:
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long.  It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.

Modified: python/trunk/Objects/abstract.c
==============================================================================
--- python/trunk/Objects/abstract.c	(original)
+++ python/trunk/Objects/abstract.c	Fri Feb 15 13:14:32 2008
@@ -1275,7 +1275,11 @@
 	else if (PyInt_Check(index))
 	  	res = _PyInt_Format((PyIntObject*)index, base, 1);
 	else
-		assert("PyNumber_ToBase: not long or int");
+		/* It should not be possible to get here, as
+		   PyNumber_Index already has a check for the same
+		   condition */
+		PyErr_SetString(PyExc_ValueError, "PyNumber_ToBase: index not "
+				"int or long");
 	Py_DECREF(index);
 	return res;
 }


More information about the Python-checkins mailing list