|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. When your account is ready, please add a comment in this pull request Thanks again for your contribution, we look forward to reviewing it! |
|
CLA signed. |
|
Would be nice to add tests. Python implementation in |
|
I'll look into tests. The Python implementation in 209 │ try:
210 │ line_buffering = False
211 │ if buffering == 1 or buffering < 0 and raw.isatty():
212 │ buffering = -1
213 │ line_buffering = TrueSince it is left to right. But maybe I am missing something else here? Regarding CLA: It is signed, I got the copy via E-Mail and my Github account is linked in the Python Bugtracker .. I'll double check it again (maybe it takes a while?). Also regarding the Misc/News, is that worth a news entry, it's just a rather small bugfix/improvement? |
|
A news entry may save hours for somebody if his program will fail when run on different computer with older Python because of this change. The Python implementation looks fine to me too. |
There was a problem hiding this comment.
I would prefer to have an else block to initialize isatty variable, even if it's not used in practice. ("else { isatty = 0; }"). Or initialize the variable to 0 when it's declared?
It should prevent warning from dummy compilers.
There was a problem hiding this comment.
Or add
if (isatty) {
buffering = 1;
}and simplify the condition (buffering == 1 || (buffering < 0 && isatty)) below to just (buffering == 1).
There was a problem hiding this comment.
Changed. isatty is now initialized and the redundant buffering < 0 below has been removed.
|
I changed the code you commented on, I turned the now redundant I also added a news entry, I hope that is proper English and makes sense for a bystander. I am still having troubles with writing tests for this though. My initial idea was to replace the FileIO = self.io.FileIO
class SpyFileIO(FileIO):
_isatty = False
def isatty(self):
SpyFileIO._isatty = True
return False
self.io.FileIO = SpyFileIO
try:
f = self.open(TESTFN, 'w', buffering=-1)
finally:
self.io.FileIO = FileIO
f.close()
self.assertTrue(SpyFileIO._isatty)This works fine for the |
There was a problem hiding this comment.
LGTM without tests. Thanks @Dav1dde!
Just a small formatting nit.
There was a problem hiding this comment.
Use double backquotes:
``buffering=-1``This is a reStructuredText, not Markdown.
There was a problem hiding this comment.
Done!
Sorry about that, haven't been doing enough Python recently :(
|
Any news on this? Anything I should do? |
https://bugs.python.org/issue34070
Only check for isatty when buffering actually requires the check (buffering < 0)
https://bugs.python.org/issue34070