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) *  |
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) *  |
Date: 2011-11-24 16:51 |
Patch looks good to me, but I’d like another review. |
|
|
msg148283 - (view) |
Author: Antoine Pitrou (pitrou) *  |
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) *  |
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)  |
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) *  |
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)  |
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) *  |
Date: 2012-10-06 22:34 |
I have made the doc changes. |
|
|