mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +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
|
@ -3906,6 +3906,17 @@ class MiscIOTest(unittest.TestCase):
|
|||
self.open(support.TESTFN, mode)
|
||||
self.assertIn('invalid mode', str(cm.exception))
|
||||
|
||||
def test_open_pipe_with_append(self):
|
||||
# bpo-27805: Ignore ESPIPE from lseek() in open().
|
||||
r, w = os.pipe()
|
||||
self.addCleanup(os.close, r)
|
||||
f = self.open(w, 'a')
|
||||
self.addCleanup(f.close)
|
||||
# Check that the file is marked non-seekable. On Windows, however, lseek
|
||||
# somehow succeeds on pipes.
|
||||
if sys.platform != 'win32':
|
||||
self.assertFalse(f.seekable())
|
||||
|
||||
def test_io_after_close(self):
|
||||
for kwargs in [
|
||||
{"mode": "w"},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue