summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-12-12 20:03:19 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-12-12 20:03:19 (GMT)
commit00b6127097f10d7fb03ab5abcd213141b878a8fd (patch)
tree8bf715d0dc1d8c9c515629b90382bab2175374bf /Objects/stringobject.c
parent63b4dd33c99bcad84fb928f874c133968d784632 (diff)
downloadcpython-00b6127097f10d7fb03ab5abcd213141b878a8fd.zip
cpython-00b6127097f10d7fb03ab5abcd213141b878a8fd.tar.gz
cpython-00b6127097f10d7fb03ab5abcd213141b878a8fd.tar.bz2
Patch #650653: Raise always value error if the table is not 256 bytes long.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 3a69aa9..7937b46 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -2070,6 +2070,12 @@ string_translate(PyStringObject *self, PyObject *args)
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 @@ string_translate(PyStringObject *self, PyObject *args)
#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;