This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients hathawsh, martin.panter, vstinner, ztane
Date 2016-08-20.12:36:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAMpsgwYC6SoJ0EDRgEzysRZtamF6idtWwNbk3ENwC27wH=fS2Q@mail.gmail.com>
In-reply-to <1471693909.21.0.0325365699615.issue27805@psf.upfronthosting.co.za>
Content
Antti Haapala added the comment:
> Presumably the case was that a *named* log file is opened with 'a' mode, and one could pass '/dev/stdout' just like any other name of a file, and it did work, but not in Python 3.5.

Oh ok, in this case, you need something smarter like:

mode = 'a' if not stat.S_ISCHR(os.stat(filename).st_mode) else 'w'
fp = open(filename, mode)

or something like (emulate append mode, but catch ESPIPE):

fp = open(filename, 'w')
try:
  fp.seek(0, os.SEEK_END)
except OSError as exc:
  if exc.errno != errno.ESPIPE: raise
History
Date User Action Args
2016-08-20 12:36:06vstinnersetrecipients: + vstinner, hathawsh, martin.panter, ztane
2016-08-20 12:36:06vstinnerlinkissue27805 messages
2016-08-20 12:36:06vstinnercreate