Marc-Andre Lemburg added the comment:
On 02.12.2015 20:16, Serhiy Storchaka wrote:
>
> Serhiy Storchaka added the comment:
>
>> If the StreamWriter/Reader cannot pickle the underlying stream (which is
>> probably always the case), why should the object itself be pickleable ?
>
> io.BytesIO() and io.StringIO() are pickleable.
Ok, but I still don't see the use case :-)
I think all we need to do is add a .__reduce__()
method to StreamWriter and StreamReader, which then
raises a PickleError.
Example:
>>> import sys, codecs, pickle
>>> r = codecs.getreader('latin-1')
>>> class MyReader(r):
... def __reduce__(self, *args):
... raise pickle.PickleError
...
>>> s = MyReader(sys.stdin)
>>> pickle.dumps(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __reduce__
_pickle.PickleError
> <stdin>(3)__reduce__()
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue6395>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com