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
base: main
Are you sure you want to change the base?
Conversation
|
It is not clear to me whether I should add the NEWS entry. See python/devguide#358 (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) |
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.
| self.assertEqual(raw.getvalue().decode('utf-8'), expect) | |
| self.assertEqual(raw.getvalue().decode(), expect) |
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.
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='') |
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.
| newline='') |
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.
This argument is passed because newline translation needs to be turned off. Otherwise, the tests fail on Windows.
Thank you for taking the time to review my changes.
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. |
https://bugs.python.org/issue41051