You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2010-08-05.07:20:40.957>created_at=<Date2006-04-22.16:20:51.000>labels= ['type-bug', 'library']
title='pickling files works with protocol=2.'updated_at=<Date2010-08-05.07:20:40.955>user='https://bugs.python.org/kirillsimonov'
That seems easy to fix by adding a dummy __reduce__ method to file. My
only worry is this could break file subclasses which may have ad-hoc
mechanisms implemented for pickling files.
Pickling a file is tricky. You can't just pickle the construction
parameters, you also need to save (and restore) the whole buffering
state. I'm not sure a half-working pickle solution would make a good
service to the user.
Activity
kirillsimonov commentedon Apr 22, 2006
Similarly, the __reduce__ method works for basic
objects like str, int or dict with protocol=2, but
doesn't work with protocol=1:
avassalotti commentedon Jun 28, 2009
That seems easy to fix by adding a dummy __reduce__ method to file. My
only worry is this could break file subclasses which may have ad-hoc
mechanisms implemented for pickling files.
pitrou commentedon Jun 29, 2009
Pickling a file is tricky. You can't just pickle the construction
parameters, you also need to save (and restore) the whole buffering
state. I'm not sure a half-working pickle solution would make a good
service to the user.
merwok commentedon May 9, 2010
Antoine, I think the goal here is to disable pickling, not making it work.
Alexandre, is it ok for a class to define pickle magic methods just to raise an exception? Doesn’t it break expectations?
One question hasn’t been answered: When did the protocol change? Was it intentional or is it a bug?
avassalotti commentedon Aug 5, 2010
Although it is tempting to fix this, it feels to much like a feature. I am closing as won't fix because we don't add new features to 2.x.