mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
Issue #9957: SpooledTemporaryFile.truncate() now accepts an optional size parameter, as other file-like objects.
Patch by Ryan Kelly.
This commit is contained in:
parent
e333d00d3a
commit
0e86a5842d
3 changed files with 31 additions and 3 deletions
|
@ -578,8 +578,13 @@ class SpooledTemporaryFile:
|
|||
def tell(self):
|
||||
return self._file.tell()
|
||||
|
||||
def truncate(self):
|
||||
self._file.truncate()
|
||||
def truncate(self, size=None):
|
||||
if size is None:
|
||||
self._file.truncate()
|
||||
else:
|
||||
if size > self._max_size:
|
||||
self.rollover()
|
||||
self._file.truncate(size)
|
||||
|
||||
def write(self, s):
|
||||
file = self._file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue