Issue 9957: SpooledTemporayFile.truncate should take size parameter (original) (raw)

Created on 2010-09-27 02:02 by rfk, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
spooledtemporaryfile_truncate.patch rfk,2010-09-27 21:42
Messages (11)
msg117436 - (view) Author: Ryan Kelly (rfk) Date: 2010-09-27 02:02
Both file.truncate() and StringIO.truncate() accept an optional "size" parameter to truncate the file to a specific size. SpooledTemporaryFile should accept a similar parameter and pass it on. The only tricky part is that truncate can potentially increase the size of a file, so it needs to check the max size and rollover if appropriate. Patch is against py3k branch; should work on trunk modulo the use of b"xxx" in the tests.
msg117469 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-27 20:06
Thank you for the report and patch. Not sure if this a bug or a new feature. Patch looks good, thanks for including a test too!. Can you also edit the documentation? (There are very minor whitespace nits in the patch, but I leave it to Georg to fix them or ignore them.)
msg117477 - (view) Author: Ryan Kelly (rfk) Date: 2010-09-27 21:42
I went looking for places to update the documentation but the description of SpooledTemporaryFile doesn't go into any detail of its methods, so I haven't added anything. New patch fixes some whitespace issues. I'd like to argue that this is a bug, since SpooledTemporaryFile is documented as "operates exactly as TemporaryFile() does", and TemporaryFile.truncate accepts a "size" parameter.
msg148281 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-24 16:51
Patch looks good to me, but I’d like another review.
msg148283 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-24 17:47
Looks ok to me as well. I think this is a new feature, so 3.3-only IMHO.
msg148335 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-25 16:46
Okay, then stable branches need a doc/docstring patch to remove the statement that SpooledTemporaryFile “operates exactly as TemporaryFile does”. Ryan, would you like to do that patch too? Antoine, will you commit?
msg148339 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-25 17:08
New changeset 5a6911930bad by Antoine Pitrou in branch 'default': Issue #9957: SpooledTemporaryFile.truncate() now accepts an optional size parameter, as other file-like objects. http://hg.python.org/cpython/rev/5a6911930bad
msg148340 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-25 17:09
Committed, thank you. By the way, Ryan, we now use Mercurial for developing, the Subversion repository is obsolete (see the devguide for more info).
msg171701 - (view) Author: Wael Al Jishi (Wael.Al.Jishi) Date: 2012-10-01 10:33
Shouldn't this issue be closed, or is there more to be done?
msg172255 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-06 22:33
New changeset 63c3a3f28b42 by R David Murray in branch '2.7': #9957: document that SpooledTemporaryFile.truncate does not take size arg http://hg.python.org/cpython/rev/63c3a3f28b42 New changeset 145480af0d78 by R David Murray in branch '3.2': #9957: document that SpooledTemporaryFile.truncate does not take size arg http://hg.python.org/cpython/rev/145480af0d78 New changeset 76feae02f48f by R David Murray in branch '3.3': #9957: document that SpooledTemporaryFile.truncate now accepts a size arg http://hg.python.org/cpython/rev/76feae02f48f New changeset c7840999b65d by R David Murray in branch 'default': merge #9957: document that SpooledTemporaryFile.truncate now accepts a size arg http://hg.python.org/cpython/rev/c7840999b65d
msg172256 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-10-06 22:34
I have made the doc changes.
History
Date User Action Args
2022-04-11 14:57:06 admin set github: 54166
2012-10-06 22:34:03 r.david.murray set status: open -> closednosy: + r.david.murraymessages: + resolution: fixedstage: patch review -> resolved
2012-10-06 22:33:30 python-dev set messages: +
2012-10-01 10:33:08 Wael.Al.Jishi set nosy: + Wael.Al.Jishimessages: +
2011-11-25 17:09:03 pitrou set messages: +
2011-11-25 17:08:10 python-dev set nosy: + python-devmessages: +
2011-11-25 16:46:02 eric.araujo set messages: +
2011-11-24 22:19:37 ncoghlan set versions: - Python 2.7, Python 3.2
2011-11-24 17:47:01 pitrou set nosy: + pitroumessages: +
2011-11-24 16:51:23 eric.araujo set versions: + Python 2.7, Python 3.3nosy: + ncoghlanmessages: + type: enhancement -> behavior
2010-09-27 21:42:42 rfk set files: - spooledtemporaryfile_truncate.patch
2010-09-27 21:42:31 rfk set files: + spooledtemporaryfile_truncate.patchmessages: +
2010-09-27 20:06:12 eric.araujo set nosy: + eric.araujomessages: +
2010-09-27 19:58:14 ned.deily set nosy: + georg.brandlstage: patch reviewtype: behavior -> enhancementversions: + Python 3.2
2010-09-27 02:02:29 rfk create