Message255761
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__() |
|
Date |
User |
Action |
Args |
2015-12-02 19:55:53 | lemburg | set | recipients:
+ lemburg, alexandre.vassalotti, ThomasH, serhiy.storchaka |
2015-12-02 19:55:53 | lemburg | link | issue6395 messages |
2015-12-02 19:55:53 | lemburg | create | |
|