MCPcopy Index your code
hub / github.com/python/cpython / truncate

Method truncate

Lib/_pyio.py:787–800  ·  view source on GitHub ↗
(self, pos=None)

Source from the content-addressed store, hash-verified

785 return pos
786
787 def truncate(self, pos=None):
788 self._checkClosed()
789 self._checkWritable()
790
791 # Flush the stream. We're mixing buffered I/O with lower-level I/O,
792 # and a flush may be necessary to synch both views of the current
793 # file state.
794 self.flush()
795
796 if pos is None:
797 pos = self.tell()
798 # XXX: Should seek() be used, instead of passing the position
799 # XXX directly to truncate?
800 return self.raw.truncate(pos)
801
802 ### Flush and close ###
803

Callers

nothing calls this directly

Calls 5

flushMethod · 0.95
tellMethod · 0.95
_checkClosedMethod · 0.45
_checkWritableMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected