New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpooledTemporayFile.truncate should take size parameter #54166
Comments
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. |
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.) |
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. |
Patch looks good to me, but I’d like another review. |
Looks ok to me as well. I think this is a new feature, so 3.3-only IMHO. |
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? |
New changeset 5a6911930bad by Antoine Pitrou in branch 'default': |
Committed, thank you. By the way, Ryan, we now use Mercurial for developing, the Subversion repository is obsolete (see the devguide for more info). |
Shouldn't this issue be closed, or is there more to be done? |
New changeset 63c3a3f28b42 by R David Murray in branch '2.7': New changeset 145480af0d78 by R David Murray in branch '3.2': New changeset 76feae02f48f by R David Murray in branch '3.3': New changeset c7840999b65d by R David Murray in branch 'default': |
I have made the doc changes. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: