Skip to content
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

bpo-41051: Flush file after warning is written #21000

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manueljacob
Copy link

@manueljacob manueljacob commented Jun 20, 2020

@manueljacob
Copy link
Author

manueljacob commented Jun 20, 2020

It is not clear to me whether I should add the NEWS entry. See python/devguide#358 (comment).

Copy link
Contributor

@remilapeyre remilapeyre left a comment

Hi @manueljacob, thanks for contributing to Python. Since this change changes the way warnings behave I think a News entry should be added to document it.

line_num)
self.module.showwarning(message, category, file_name, line_num,
file_object)
self.assertEqual(raw.getvalue().decode('utf-8'), expect)
Copy link
Contributor

@remilapeyre remilapeyre Jun 20, 2020

Choose a reason for hiding this comment

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

Suggested change
self.assertEqual(raw.getvalue().decode('utf-8'), expect)
self.assertEqual(raw.getvalue().decode(), expect)

Copy link
Author

@manueljacob manueljacob Jun 21, 2020

Choose a reason for hiding this comment

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

First, I omitted it, but then I added it to make it consistent with passing the encoding to TextIOWrapper (which I think should stay). But I don’t feel as strong about this one and would be fine with omitting it.

# Test that file is flushed after writing the warning.
raw = BytesIO()
file_object = TextIOWrapper(BufferedWriter(raw), 'utf-8',
newline='')
Copy link
Contributor

@remilapeyre remilapeyre Jun 20, 2020

Choose a reason for hiding this comment

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

Suggested change
newline='')

Copy link
Author

@manueljacob manueljacob Jun 21, 2020

Choose a reason for hiding this comment

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

This argument is passed because newline translation needs to be turned off. Otherwise, the tests fail on Windows.

Lib/test/test_warnings/__init__.py Show resolved Hide resolved
@manueljacob
Copy link
Author

manueljacob commented Jun 21, 2020

Hi @manueljacob, thanks for contributing to Python.

Thank you for taking the time to review my changes.

Since this change changes the way warnings behave I think a News entry should be added to document it.

Clearly, a NEWS entry should be added, but it’s not clear whether I or a core developer should do it. Maybe the recommendation that a core developer does it is outdated since the adoption of blurb made merge conflicts impossible?

I’ll wait a bit until this is clarified and if there’s no clear answer to the question, I’ll go ahead with adding an entry Sunday or Monday.

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.

None yet

5 participants