This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SpooledTemporayFile.truncate should take size parameter
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Wael.Al.Jishi, eric.araujo, georg.brandl, ncoghlan, pitrou, python-dev, r.david.murray, rfk
Priority: normal Keywords: patch

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:06adminsetgithub: 54166
2012-10-06 22:34:03r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg172256

resolution: fixed
stage: patch review -> resolved
2012-10-06 22:33:30python-devsetmessages: + msg172255
2012-10-01 10:33:08Wael.Al.Jishisetnosy: + Wael.Al.Jishi
messages: + msg171701
2011-11-25 17:09:03pitrousetmessages: + msg148340
2011-11-25 17:08:10python-devsetnosy: + python-dev
messages: + msg148339
2011-11-25 16:46:02eric.araujosetmessages: + msg148335
2011-11-24 22:19:37ncoghlansetversions: - Python 2.7, Python 3.2
2011-11-24 17:47:01pitrousetnosy: + pitrou
messages: + msg148283
2011-11-24 16:51:23eric.araujosetversions: + Python 2.7, Python 3.3
nosy: + ncoghlan

messages: + msg148281

type: enhancement -> behavior
2010-09-27 21:42:42rfksetfiles: - spooledtemporaryfile_truncate.patch
2010-09-27 21:42:31rfksetfiles: + spooledtemporaryfile_truncate.patch

messages: + msg117477
2010-09-27 20:06:12eric.araujosetnosy: + eric.araujo
messages: + msg117469
2010-09-27 19:58:14ned.deilysetnosy: + georg.brandl
stage: patch review
type: behavior -> enhancement

versions: + Python 3.2
2010-09-27 02:02:29rfkcreate