From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 17 Apr 2020 07:14:55 +0000 (-0700) Subject: bpo-40287: Fix SpooledTemporaryFile.seek() return value (GH-19540) X-Git-Tag: v3.8.3rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9796fe88da7415925b3e8f7e0a5e55301548734f;p=thirdparty%2FPython%2Fcpython.git bpo-40287: Fix SpooledTemporaryFile.seek() return value (GH-19540) It has not returned the file position after the seek. (cherry picked from commit 485e715cb1ff92bc9882cd51ec32589f9cb30503) Co-authored-by: Inada Naoki --- diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 62875540f8b9..5b990e067f23 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -735,7 +735,7 @@ class SpooledTemporaryFile: return self._file.readlines(*args) def seek(self, *args): - self._file.seek(*args) + return self._file.seek(*args) @property def softspace(self): diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index 232c5dae10fd..f129454f4c33 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -1025,7 +1025,8 @@ class TestSpooledTemporaryFile(BaseTestCase): # Verify writelines with a SpooledTemporaryFile f = self.do_create() f.writelines((b'x', b'y', b'z')) - f.seek(0) + pos = f.seek(0) + self.assertEqual(pos, 0) buf = f.read() self.assertEqual(buf, b'xyz') @@ -1043,7 +1044,8 @@ class TestSpooledTemporaryFile(BaseTestCase): # when that occurs f = self.do_create(max_size=30) self.assertFalse(f._rolled) - f.seek(100, 0) + pos = f.seek(100, 0) + self.assertEqual(pos, 100) self.assertFalse(f._rolled) f.write(b'x') self.assertTrue(f._rolled) diff --git a/Misc/NEWS.d/next/Library/2020-04-15-17-21-48.bpo-40287.-mkEJH.rst b/Misc/NEWS.d/next/Library/2020-04-15-17-21-48.bpo-40287.-mkEJH.rst new file mode 100644 index 000000000000..d4db192b7107 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-04-15-17-21-48.bpo-40287.-mkEJH.rst @@ -0,0 +1 @@ +Fixed ``SpooledTemporaryFile.seek()`` to return the position.