Skip to content

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

Closed
wants to merge 1 commit into from
Closed

gh-94350: mailbox: Remove support for text mode files #94351

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 27, 2022

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.

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.
@vstinner
Copy link
Member Author

cc @bitdancer

@vstinner vstinner marked this pull request as ready for review June 27, 2022 22:11
@vstinner vstinner requested a review from a team as a code owner June 27, 2022 22:11
@@ -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):
Copy link
Member

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it removed?

Copy link
Member Author

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?

Copy link
Member

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.

@vstinner
Copy link
Member Author

Curently, mailbox docuemntation says:

text mode files are accepted for backward compatibility

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".

@vstinner
Copy link
Member Author

vstinner commented Jul 4, 2022

Ping @serhiy-storchaka, I didn't understand your comment about StringIO removal. See my reply.

@vstinner
Copy link
Member Author

vstinner commented Nov 4, 2022

@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

@vstinner vstinner closed this Nov 4, 2022
@vstinner vstinner deleted the mailbox branch November 4, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants