-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-94350: mailbox: Remove support for text mode files #94351
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
Conversation
The mailbox module now only accepts binary files and BytesIO: text mode files and StringIO are no longer accepted. The support fort text mode files was deprecated since Python 3.2.
|
cc @bitdancer |
| @@ -1431,10 +1422,6 @@ def _install_message(self, message): | |||
| break | |||
| self._file.write(buffer.replace(b'\n', linesep)) | |||
| elif isinstance(message, (bytes, str, io.StringIO)): | |||
| if isinstance(message, io.StringIO): | |||
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.
Why is it removed?
| @@ -222,10 +221,6 @@ def _dump_message(self, message, target, mangle_from_=False): | |||
| # Make sure the message ends with a newline | |||
| target.write(linesep) | |||
| elif isinstance(message, (str, bytes, io.StringIO)): | |||
| if isinstance(message, io.StringIO): | |||
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.
Why is it removed?
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.
Because this code path was deprecated and the PR removes deprecated code. Are you suggesting something else? Or keep the code and remove the deprecation warning?
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.
Look at the line above. It contains explicit support for StringIO. It should be updated too. There may be other code related to support of StringIO.
And we still need tests. The use of StringIO etc should now result in error instead of warning.
|
Curently, mailbox docuemntation says:
For the new documentation, I hesitate between "text mode files" or just "text files". It's the first time that I see "text mode files". |
|
Ping @serhiy-storchaka, I didn't understand your comment about StringIO removal. See my reply. |
|
@serhiy-storchaka never replied to my question. Anyway, I lost track of this change and I don't have the bandwidth to continue working on that. Maybe someone else can give it a try during Python 3.12 development. Otherwise, I will try again to remove the deprecated code in Python 3.13 or later. I chose to remove other deprecated functions in Python 3.12 instead ;-) See: https://discuss.python.org/t/collaboration-on-handling-python-3-12-incompatible-changes-distutils-removal-invalid-escape-escape-etc/20721/2 |
The mailbox module now only accepts binary files and BytesIO: text
mode files and StringIO are no longer accepted. The support fort text
mode files was deprecated since Python 3.2.