@@ -549,6 +549,15 @@ buffered_isatty(buffered *self, PyObject *args)
549549 return PyObject_CallMethodObjArgs (self -> raw , _PyIO_str_isatty , NULL );
550550}
551551
552+ /* Serialization */
553+
554+ static PyObject *
555+ buffered_getstate (buffered * self , PyObject * args )
556+ {
557+ PyErr_Format (PyExc_TypeError ,
558+ "cannot serialize '%s' object" , Py_TYPE (self )-> tp_name );
559+ return NULL ;
560+ }
552561
553562/* Forward decls */
554563static PyObject *
@@ -1489,6 +1498,7 @@ static PyMethodDef bufferedreader_methods[] = {
14891498 {"fileno" , (PyCFunction )buffered_fileno , METH_NOARGS },
14901499 {"isatty" , (PyCFunction )buffered_isatty , METH_NOARGS },
14911500 {"_dealloc_warn" , (PyCFunction )buffered_dealloc_warn , METH_O },
1501+ {"__getstate__" , (PyCFunction )buffered_getstate , METH_NOARGS },
14921502
14931503 {"read" , (PyCFunction )buffered_read , METH_VARARGS },
14941504 {"peek" , (PyCFunction )buffered_peek , METH_VARARGS },
@@ -1872,6 +1882,7 @@ static PyMethodDef bufferedwriter_methods[] = {
18721882 {"fileno" , (PyCFunction )buffered_fileno , METH_NOARGS },
18731883 {"isatty" , (PyCFunction )buffered_isatty , METH_NOARGS },
18741884 {"_dealloc_warn" , (PyCFunction )buffered_dealloc_warn , METH_O },
1885+ {"__getstate__" , (PyCFunction )buffered_getstate , METH_NOARGS },
18751886
18761887 {"write" , (PyCFunction )bufferedwriter_write , METH_VARARGS },
18771888 {"truncate" , (PyCFunction )buffered_truncate , METH_VARARGS },
@@ -2137,6 +2148,8 @@ static PyMethodDef bufferedrwpair_methods[] = {
21372148 {"close" , (PyCFunction )bufferedrwpair_close , METH_NOARGS },
21382149 {"isatty" , (PyCFunction )bufferedrwpair_isatty , METH_NOARGS },
21392150
2151+ {"__getstate__" , (PyCFunction )buffered_getstate , METH_NOARGS },
2152+
21402153 {NULL , NULL }
21412154};
21422155
@@ -2257,6 +2270,7 @@ static PyMethodDef bufferedrandom_methods[] = {
22572270 {"fileno" , (PyCFunction )buffered_fileno , METH_NOARGS },
22582271 {"isatty" , (PyCFunction )buffered_isatty , METH_NOARGS },
22592272 {"_dealloc_warn" , (PyCFunction )buffered_dealloc_warn , METH_O },
2273+ {"__getstate__" , (PyCFunction )buffered_getstate , METH_NOARGS },
22602274
22612275 {"flush" , (PyCFunction )buffered_flush , METH_NOARGS },
22622276
0 commit comments