bpo-40287: Fix SpooledTemporaryFile.seek() return value (GH-19540)

It has not returned the file position after the seek.
This commit is contained in:
Inada Naoki 2020-04-17 15:56:35 +09:00 committed by GitHub
parent bf1a81258c
commit 485e715cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -738,7 +738,7 @@ class SpooledTemporaryFile:
return self._file.readlines(*args) return self._file.readlines(*args)
def seek(self, *args): def seek(self, *args):
self._file.seek(*args) return self._file.seek(*args)
def tell(self): def tell(self):
return self._file.tell() return self._file.tell()

View File

@ -1018,7 +1018,8 @@ class TestSpooledTemporaryFile(BaseTestCase):
# Verify writelines with a SpooledTemporaryFile # Verify writelines with a SpooledTemporaryFile
f = self.do_create() f = self.do_create()
f.writelines((b'x', b'y', b'z')) f.writelines((b'x', b'y', b'z'))
f.seek(0) pos = f.seek(0)
self.assertEqual(pos, 0)
buf = f.read() buf = f.read()
self.assertEqual(buf, b'xyz') self.assertEqual(buf, b'xyz')
@ -1036,7 +1037,8 @@ class TestSpooledTemporaryFile(BaseTestCase):
# when that occurs # when that occurs
f = self.do_create(max_size=30) f = self.do_create(max_size=30)
self.assertFalse(f._rolled) self.assertFalse(f._rolled)
f.seek(100, 0) pos = f.seek(100, 0)
self.assertEqual(pos, 100)
self.assertFalse(f._rolled) self.assertFalse(f._rolled)
f.write(b'x') f.write(b'x')
self.assertTrue(f._rolled) self.assertTrue(f._rolled)

View File

@ -0,0 +1 @@
Fixed ``SpooledTemporaryFile.seek()`` to return the position.