[Python-checkins] bpo-40287: Fix SpooledTemporaryFile.seek() return value (GH-19540)
Miss Islington (bot)
webhook-mailer at python.org
Fri Apr 17 03:13:39 EDT 2020
https://github.com/python/cpython/commit/11ae7d075293fe855c8af26b577656d1026cd9bb
commit: 11ae7d075293fe855c8af26b577656d1026cd9bb
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-04-17T00:13:34-07:00
summary:
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 <songofacandy at gmail.com>
files:
A Misc/NEWS.d/next/Library/2020-04-15-17-21-48.bpo-40287.-mkEJH.rst
M Lib/tempfile.py
M Lib/test/test_tempfile.py
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 24f673c64aa8d..f92db5313215e 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -744,7 +744,7 @@ def readlines(self, *args):
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 c0464200a3aa3..2d47e70bd0328 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -1034,7 +1034,8 @@ def test_writelines(self):
# 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')
@@ -1052,7 +1053,8 @@ def test_sparse(self):
# 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 0000000000000..d4db192b71076
--- /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.
More information about the Python-checkins
mailing list