diff options
author | Benjamin Peterson <benjamin@python.org> | 2019-11-12 23:54:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-12 23:54:19 (GMT) |
commit | 9788f97bf69230ec6b38a483c90e88828eba9a1b (patch) | |
tree | 8aed2b627f322c342d8e0df3aa65cb050c9f78ba /Lib/_pyio.py | |
parent | 0a8e7fde064c8fb6eb8e78752d4bcdab56643065 (diff) | |
download | cpython-9788f97bf69230ec6b38a483c90e88828eba9a1b.zip cpython-9788f97bf69230ec6b38a483c90e88828eba9a1b.tar.gz cpython-9788f97bf69230ec6b38a483c90e88828eba9a1b.tar.bz2 |
[3.8] closes bpo-27805: Ignore ESPIPE in initializing seek of append-mode files. (GH-17136)
This change, which follows the behavior of C stdio's fdopen and Python 2's file object, allows pipes to be opened in append mode..
(cherry picked from commit 74fa9f723f700a342e582b5ad4b51a2c4801cd1c)
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index eb4e662..fd31b8c 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1587,7 +1587,11 @@ class FileIO(RawIOBase): # For consistent behaviour, we explicitly seek to the # end of file (otherwise, it might be done only on the # first write()). - os.lseek(fd, 0, SEEK_END) + try: + os.lseek(fd, 0, SEEK_END) + except OSError as e: + if e.errno != errno.ESPIPE: + raise except: if owned_fd is not None: os.close(owned_fd) |