diff Objects/stringobject.c @ 26625:ba1578be5706 legacy-trunk

Patch #650653: Raise always value error if the table is not 256 bytes long.
author Martin v. Löwis <martin@v.loewis.de>
date Thu, 12 Dec 2002 20:03:19 +0000
parents b9c912e2c3c0
children e094a03a80ff
line wrap: on
line diff
--- a/Objects/stringobject.c	Thu Dec 12 19:35:00 2002 +0000
+++ b/Objects/stringobject.c	Thu Dec 12 20:03:19 2002 +0000
@@ -2070,6 +2070,12 @@
 	else if (PyObject_AsCharBuffer(tableobj, &table1, &tablen))
 		return NULL;
 
+	if (tablen != 256) {
+		PyErr_SetString(PyExc_ValueError,
+		  "translation table must be 256 characters long");
+		return NULL;
+	}
+
 	if (delobj != NULL) {
 		if (PyString_Check(delobj)) {
 			del_table = PyString_AS_STRING(delobj);
@@ -2084,12 +2090,6 @@
 #endif
 		else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen))
 			return NULL;
-
-		if (tablen != 256) {
-			PyErr_SetString(PyExc_ValueError,
-			  "translation table must be 256 characters long");
-			return NULL;
-		}
 	}
 	else {
 		del_table = NULL;