- Issue #6939: Fix file I/O objects in the `io` module to keep the original
file position when calling `truncate()`. It would previously change the
file position to the given argument, which goes against the tradition of
ftruncate() and other truncation APIs. Patch by Pascal Chambon.
diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py
index c4faead..16da8d8 100644
--- a/Lib/test/test_largefile.py
+++ b/Lib/test/test_largefile.py
@@ -125,7 +125,7 @@
f.seek(42)
f.truncate(newsize)
if self.new_io:
- self.assertEqual(f.tell(), newsize) # else wasn't truncated
+ self.assertEqual(f.tell(), 42)
f.seek(0, 2)
self.assertEqual(f.tell(), newsize)
# XXX truncate(larger than true size) is ill-defined
@@ -133,7 +133,7 @@
f.seek(0)
f.truncate(1)
if self.new_io:
- self.assertEqual(f.tell(), 1) # else pointer moved
+ self.assertEqual(f.tell(), 0) # else pointer moved
f.seek(0)
self.assertEqual(len(f.read()), 1) # else wasn't truncated