summaryrefslogtreecommitdiff
path: root/Lib/test/test_tempfile.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-11-30 00:16:44 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-11-30 00:16:44 +0000
commit36dfe784568b2d01bc03b3151ff6974b8ba42acf (patch)
treedd4f4fd5f97578d2a0e5d4b6a12c22de73757b08 /Lib/test/test_tempfile.py
parentac4a07c714fbe5560cd1204c1335e5fcea4b2ef3 (diff)
downloadcpython-git-36dfe784568b2d01bc03b3151ff6974b8ba42acf.tar.gz
Merged revisions 76593 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76593 | amaury.forgeotdarc | 2009-11-30 01:08:56 +0100 (lun., 30 nov. 2009) | 5 lines #6077: on Windows, fix truncation of a tempfile.TemporaryFile opened in "wt+" mode: files opened with os.open() stop on the first \x1a (Ctrl-Z) unless os.O_BINARY is used. Will backport to 3.1 ........
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r--Lib/test/test_tempfile.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index a1bafc25c5..403dd93594 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -309,8 +309,12 @@ class test__mkstemp_inner(TC):
if not has_textmode:
return # ugh, can't use SkipTest.
- self.do_create(bin=0).write(b"blat\n")
- # XXX should test that the file really is a text file
+ # A text file is truncated at the first Ctrl+Z byte
+ f = self.do_create(bin=0)
+ f.write(b"blat\x1a")
+ f.write(b"extra\n")
+ os.lseek(f.fd, 0, os.SEEK_SET)
+ self.assertEquals(os.read(f.fd, 20), b"blat")
test_classes.append(test__mkstemp_inner)
@@ -761,6 +765,10 @@ class test_SpooledTemporaryFile(TC):
f.write("xyzzy\n")
f.seek(0)
self.assertEqual(f.read(), "abc\ndef\nxyzzy\n")
+ # Check that Ctrl+Z doesn't truncate the file
+ f.write("foo\x1abar\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "abc\ndef\nxyzzy\nfoo\x1abar\n")
def test_text_newline_and_encoding(self):
f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10,