This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lemburg
Recipients ThomasH, alexandre.vassalotti, lemburg, serhiy.storchaka
Date 2015-12-02.19:55:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <565F4CC4.1030405@egenix.com>
In-reply-to <1449083804.49.0.848808704207.issue6395@psf.upfronthosting.co.za>
Content
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__()
History
Date User Action Args
2015-12-02 19:55:53lemburgsetrecipients: + lemburg, alexandre.vassalotti, ThomasH, serhiy.storchaka
2015-12-02 19:55:53lemburglinkissue6395 messages
2015-12-02 19:55:53lemburgcreate