New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File objects should not pickleable #54389
Comments
In Python 3, pickle accepts to serialize a file object, but the result is nonsensical when unpickled. I think we should explicitly forbid pickling of FileIO, Buffered{Reader,Writer} and TextIOWrapper objects. |
Sounds like a good idea to me. |
Here is a patch, but bpo-10173 must probably be fixed first. |
The patch modifies _io.TextIOWrapper, but not _pyio.TextIOWrapper. Is there a reason? |
Yes, two of them:
|
I don't see why Buffered or TextIO's shouldn't be pickleable, ISTM their pickleability should be based on what the underlying file obj is. |
What would be the use case for that? |
That could be. Right now, though, pickling them gives nonsensical (a problem with making them pickleable is that, by exposing details of |
Committed in r86220. I won't backport it since it would risk breaking existing code, although relying on this is really a bug in itself. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: