Can't open standard streams with "a"
In Python 2 you can open the standard output and error streams in append mode, despite the fact that they aren't technically seekable. This changed somewhere along the way in (I think) io.open. There's an open bug report about this: https://bugs.python.org/issue27805 I just stumbled on it porting an application from Py2 to Py3 where my default logfile is /dev/stderr. I don't ever want to truncate a user's logfile, so "a" is a nice default, but in case the user doesn't name a logfile, I have to test, just in case /dev/stderr is the candidate. This seems error-prone, and must be done in all applications. The Py2 behavior seems less error-prone. I know explicit is better than implicit, but practicality also beats purity. Also, os.open is fine with O_APPEND on these streams. Any chance of this getting into 3.7 or will a fix have to wait for 3.8 at this point? (I'm guessing "no" as I don't see a patch.) Skip
On Apr 6, 2018, at 12:06, Skip Montanaro
[...] https://bugs.python.org/issue27805 [...] Any chance of this getting into 3.7 or will a fix have to wait for 3.8 at this point? (I'm guessing "no" as I don't see a patch.)
It seems like most commenters on the issue consider the behavior to be a bug so a case could be made for a fix to go into a maintenance release, not just a feature release. But, obviously, someone needs to produce a PR for review first. -- Ned Deily nad@python.org -- []
On Fri, 6 Apr 2018 17:17:58 -0400
Ned Deily
On Apr 6, 2018, at 12:06, Skip Montanaro
wrote: [...] https://bugs.python.org/issue27805 [...] Any chance of this getting into 3.7 or will a fix have to wait for 3.8 at this point? (I'm guessing "no" as I don't see a patch.)
It seems like most commenters on the issue consider the behavior to be a bug so a case could be made for a fix to go into a maintenance release, not just a feature release. But, obviously, someone needs to produce a PR for review first.
OTOH this has never worked on Python 3, so it's hardly an important fix. If it's delicate enough, we may prefer to only ship it in 3.8. PS : it's the first time I encounter "/dev/stderr". Apparently it's a Linux-only symlink to "/proc/self/fd/2", i.e. the current process' file descriptor number 2 (which is conventionally the current process' stderr stream)! Regards Antoine.
participants (3)
-
Antoine Pitrou
-
Ned Deily
-
Skip Montanaro