mirror of
https://github.com/python/cpython.git
synced 2025-07-08 20:05:28 +00:00
closes bpo-27805: Ignore ESPIPE in initializing seek of append-mode files. (GH-17112)
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.
This commit is contained in:
parent
d593881505
commit
74fa9f723f
4 changed files with 33 additions and 10 deletions
|
@ -1577,7 +1577,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue