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.

Author lurchman
Recipients brett.cannon, docs@python, jcc2220, lurchman
Date 2019-07-07.15:58:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1562515106.06.0.498625685744.issue34446@roundup.psfhosted.org>
In-reply-to
Content
I agree that this is ambiguous behaviour. The docs at https://docs.python.org/3/library/tempfile.html#tempfile.SpooledTemporaryFile say "This function operates exactly as TemporaryFile() does, except that data is spooled in memory until the file size exceeds max_size, or until the file’s fileno() method is called, at which point the contents are written to disk and operation proceeds as with TemporaryFile().", and as the default value for max_size is 0, that would imply to me that _any_ data written to a SpooledTemporaryFile (constructed with a max_size of 0) would instantly get (internally) converted to a TemporaryFile.

Whereas looking at the code https://github.com/python/cpython/blob/master/Lib/tempfile.py#L650 it seems a max_size of 0 means "don't rollover". Perhaps it would have made sense to have SpooledTemporaryFile default to a max_size of None (and use that to mean "never rollover") ?

So as well as the inconsistency between rollover behaviour in the write()/writelines() methods and the truncate() method (when max_size is 0) that jcc2220 pointed out, I believe there's also a documentation issue here in that it's not clear what a max_size of 0 is /supposed/ to do.
History
Date User Action Args
2019-07-07 15:58:26lurchmansetrecipients: + lurchman, brett.cannon, docs@python, jcc2220
2019-07-07 15:58:26lurchmansetmessageid: <1562515106.06.0.498625685744.issue34446@roundup.psfhosted.org>
2019-07-07 15:58:26lurchmanlinkissue34446 messages
2019-07-07 15:58:25lurchmancreate