-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-50644: Forbid pickling of codecs streams #109180
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
gh-50644: Forbid pickling of codecs streams #109180
Conversation
Attempts to pickle or create a shallow or deep copy of codecs streams now raise a TypeError. Previously, stream pickling produced invalid data, which attempts to read resulted in a RecursionError, as well as attempts to create a copy of the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the minor nit with the news entry this LGTM. Thanks, Serhiy.
Attempts to pickle or create a shallow or deep copy of :mod:`codecs` streams | ||
now raise a TypeError. Previously, stream pickling produced invalid data, | ||
which attempts to read resulted in a RecursionError, as well as attempts to | ||
create a copy of the stream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better wording: Previously, unpickled or copied streams could produce invalid data and attempts to read from them resulted in a RecursionError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, maybe my English is so bad that it was misunderstood by you. The problem is:
- Attempt to pickle a stream finished successfully. But the result is incorrect, and attempt to unpickle it fails with RecursionError.
- Attempt to copy a stream fails with RecursionError.
So there is no unpickled or copied stream. You cannot unpickle or copy.
How to say this in one sentence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
Previously, both operations were possible, but produced wrong results and eventually failed with a RecursionError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it is still not completely technically correct, because copying was not possible, and pickling caused a failure on other end. How about this:
Previously, pickling produced wrong results that eventually caused unpickling to fail with a RecursionError. Copying failed with a RecursionError.
or this:
Previously, copying failed with a RecursionError, while pickling produced wrong results that eventually caused unpickling to fail with a RecursionError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are great. Sorry for the extra rounds 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I always grateful for corrections.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
GH-109231 is a backport of this pull request to the 3.12 branch. |
Attempts to pickle or create a shallow or deep copy of codecs streams now raise a TypeError. Previously, copying failed with a RecursionError, while pickling produced wrong results that eventually caused unpickling to fail with a RecursionError. (cherry picked from commit d6892c2) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-109232 is a backport of this pull request to the 3.11 branch. |
Attempts to pickle or create a shallow or deep copy of codecs streams now raise a TypeError. Previously, copying failed with a RecursionError, while pickling produced wrong results that eventually caused unpickling to fail with a RecursionError. (cherry picked from commit d6892c2) Co-authored-by: Serhiy Storchaka <[email protected]>
…9232) Attempts to pickle or create a shallow or deep copy of codecs streams now raise a TypeError. Previously, copying failed with a RecursionError, while pickling produced wrong results that eventually caused unpickling to fail with a RecursionError. (cherry picked from commit d6892c2) Co-authored-by: Serhiy Storchaka <[email protected]>
|
gh-50644: Forbid pickling of codecs streams (GH-109180) Attempts to pickle or create a shallow or deep copy of codecs streams now raise a TypeError. Previously, copying failed with a RecursionError, while pickling produced wrong results that eventually caused unpickling to fail with a RecursionError. (cherry picked from commit d6892c2) Co-authored-by: Serhiy Storchaka <[email protected]>
Attempts to pickle or create a shallow or deep copy of codecs streams now raise a TypeError.
Previously, copying failed with a RecursionError, while pickling produced wrong results that eventually caused unpickling to fail with a RecursionError.