mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Patch #650653: Raise always value error if the table is not 256 bytes long.
This commit is contained in:
parent
63b4dd33c9
commit
00b6127097
2 changed files with 8 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue