mirror of https://github.com/python/cpython
Make marshalling errors a little more informative as to what went wrong
This commit is contained in:
parent
2ace4cf813
commit
8eba5ed0d9
|
@ -576,7 +576,7 @@ r_object(RFILE *p)
|
|||
n = r_long(p);
|
||||
if (n < -INT_MAX || n > INT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"bad marshal data");
|
||||
"bad marshal data (long size out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ r_object(RFILE *p)
|
|||
if (digit < 0) {
|
||||
Py_DECREF(ob);
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"bad marshal data");
|
||||
"bad marshal data (negative digit in long)");
|
||||
ob = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ r_object(RFILE *p)
|
|||
case TYPE_STRING:
|
||||
n = r_long(p);
|
||||
if (n < 0 || n > INT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (string size out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ r_object(RFILE *p)
|
|||
case TYPE_STRINGREF:
|
||||
n = r_long(p);
|
||||
if (n < 0 || n >= PyList_GET_SIZE(p->strings)) {
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (string ref out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ r_object(RFILE *p)
|
|||
|
||||
n = r_long(p);
|
||||
if (n < 0 || n > INT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (unicode size out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ r_object(RFILE *p)
|
|||
case TYPE_TUPLE:
|
||||
n = r_long(p);
|
||||
if (n < 0 || n > INT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (tuple size out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ r_object(RFILE *p)
|
|||
if ( v2 == NULL ) {
|
||||
if (!PyErr_Occurred())
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"NULL object in marshal data");
|
||||
"NULL object in marshal data for tuple");
|
||||
Py_DECREF(v);
|
||||
v = NULL;
|
||||
break;
|
||||
|
@ -807,7 +807,7 @@ r_object(RFILE *p)
|
|||
case TYPE_LIST:
|
||||
n = r_long(p);
|
||||
if (n < 0 || n > INT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (list size out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ r_object(RFILE *p)
|
|||
if ( v2 == NULL ) {
|
||||
if (!PyErr_Occurred())
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"NULL object in marshal data");
|
||||
"NULL object in marshal data for list");
|
||||
Py_DECREF(v);
|
||||
v = NULL;
|
||||
break;
|
||||
|
@ -859,7 +859,7 @@ r_object(RFILE *p)
|
|||
case TYPE_FROZENSET:
|
||||
n = r_long(p);
|
||||
if (n < 0 || n > INT_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (set size out of range)");
|
||||
retval = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ r_object(RFILE *p)
|
|||
if ( v2 == NULL ) {
|
||||
if (!PyErr_Occurred())
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"NULL object in marshal data");
|
||||
"NULL object in marshal data for set");
|
||||
Py_DECREF(v);
|
||||
v = NULL;
|
||||
break;
|
||||
|
@ -973,7 +973,7 @@ r_object(RFILE *p)
|
|||
default:
|
||||
/* Bogus data got written, which isn't ideal.
|
||||
This will let you keep working and recover. */
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data");
|
||||
PyErr_SetString(PyExc_ValueError, "bad marshal data (unknown type code)");
|
||||
retval = NULL;
|
||||
break;
|
||||
|
||||
|
@ -992,7 +992,7 @@ read_object(RFILE *p)
|
|||
}
|
||||
v = r_object(p);
|
||||
if (v == NULL && !PyErr_Occurred())
|
||||
PyErr_SetString(PyExc_TypeError, "NULL object in marshal data");
|
||||
PyErr_SetString(PyExc_TypeError, "NULL object in marshal data for object");
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue