summaryrefslogtreecommitdiffstats
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-11-05 21:15:39 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-11-05 21:15:39 (GMT)
commit243757eb79fe4bee33882b1813cf33839117570f (patch)
treea9403be5a75dedbb5c5b6ea4ee563b7155c707fd /Modules/_io/fileio.c
parent4a5f9677f31d75454ec10a0baefef37b63568a31 (diff)
downloadcpython-243757eb79fe4bee33882b1813cf33839117570f.zip
cpython-243757eb79fe4bee33882b1813cf33839117570f.tar.gz
cpython-243757eb79fe4bee33882b1813cf33839117570f.tar.bz2
Issue #10180: Pickling file objects is now explicitly forbidden, since
unpickling them produced nonsensical results.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r--Modules/_io/fileio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 09ea80f..96fce15 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -952,6 +952,14 @@ fileio_isatty(fileio *self)
return PyBool_FromLong(res);
}
+static PyObject *
+fileio_getstate(fileio *self)
+{
+ PyErr_Format(PyExc_TypeError,
+ "cannot serialize '%s' object", Py_TYPE(self)->tp_name);
+ return NULL;
+}
+
PyDoc_STRVAR(fileio_doc,
"file(name: str[, mode: str]) -> file IO object\n"
@@ -1046,6 +1054,7 @@ static PyMethodDef fileio_methods[] = {
{"fileno", (PyCFunction)fileio_fileno, METH_NOARGS, fileno_doc},
{"isatty", (PyCFunction)fileio_isatty, METH_NOARGS, isatty_doc},
{"_dealloc_warn", (PyCFunction)fileio_dealloc_warn, METH_O, NULL},
+ {"__getstate__", (PyCFunction)fileio_getstate, METH_NOARGS, NULL},
{NULL, NULL} /* sentinel */
};