mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #10180: Pickling file objects is now explicitly forbidden, since
unpickling them produced nonsensical results.
This commit is contained in:
parent
4a5f9677f3
commit
243757eb79
6 changed files with 57 additions and 0 deletions
|
@ -549,6 +549,15 @@ buffered_isatty(buffered *self, PyObject *args)
|
|||
return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_isatty, NULL);
|
||||
}
|
||||
|
||||
/* Serialization */
|
||||
|
||||
static PyObject *
|
||||
buffered_getstate(buffered *self, PyObject *args)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"cannot serialize '%s' object", Py_TYPE(self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Forward decls */
|
||||
static PyObject *
|
||||
|
@ -1489,6 +1498,7 @@ static PyMethodDef bufferedreader_methods[] = {
|
|||
{"fileno", (PyCFunction)buffered_fileno, METH_NOARGS},
|
||||
{"isatty", (PyCFunction)buffered_isatty, METH_NOARGS},
|
||||
{"_dealloc_warn", (PyCFunction)buffered_dealloc_warn, METH_O},
|
||||
{"__getstate__", (PyCFunction)buffered_getstate, METH_NOARGS},
|
||||
|
||||
{"read", (PyCFunction)buffered_read, METH_VARARGS},
|
||||
{"peek", (PyCFunction)buffered_peek, METH_VARARGS},
|
||||
|
@ -1872,6 +1882,7 @@ static PyMethodDef bufferedwriter_methods[] = {
|
|||
{"fileno", (PyCFunction)buffered_fileno, METH_NOARGS},
|
||||
{"isatty", (PyCFunction)buffered_isatty, METH_NOARGS},
|
||||
{"_dealloc_warn", (PyCFunction)buffered_dealloc_warn, METH_O},
|
||||
{"__getstate__", (PyCFunction)buffered_getstate, METH_NOARGS},
|
||||
|
||||
{"write", (PyCFunction)bufferedwriter_write, METH_VARARGS},
|
||||
{"truncate", (PyCFunction)buffered_truncate, METH_VARARGS},
|
||||
|
@ -2137,6 +2148,8 @@ static PyMethodDef bufferedrwpair_methods[] = {
|
|||
{"close", (PyCFunction)bufferedrwpair_close, METH_NOARGS},
|
||||
{"isatty", (PyCFunction)bufferedrwpair_isatty, METH_NOARGS},
|
||||
|
||||
{"__getstate__", (PyCFunction)buffered_getstate, METH_NOARGS},
|
||||
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -2257,6 +2270,7 @@ static PyMethodDef bufferedrandom_methods[] = {
|
|||
{"fileno", (PyCFunction)buffered_fileno, METH_NOARGS},
|
||||
{"isatty", (PyCFunction)buffered_isatty, METH_NOARGS},
|
||||
{"_dealloc_warn", (PyCFunction)buffered_dealloc_warn, METH_O},
|
||||
{"__getstate__", (PyCFunction)buffered_getstate, METH_NOARGS},
|
||||
|
||||
{"flush", (PyCFunction)buffered_flush, METH_NOARGS},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue