MCPcopy Index your code
hub / github.com/RustPython/RustPython / seek

Method seek

Lib/_pyio.py:1407–1422  ·  view source on GitHub ↗
(self, pos, whence=0)

Source from the content-addressed store, hash-verified

1405 BufferedWriter.__init__(self, raw, buffer_size)
1406
1407 def seek(self, pos, whence=0):
1408 if whence not in valid_seek_flags:
1409 raise ValueError("invalid whence value")
1410 self.flush()
1411 if self._read_buf:
1412 # Undo read ahead.
1413 with self._read_lock:
1414 self.raw.seek(self._read_pos - len(self._read_buf), 1)
1415 # First do the raw seek, then empty the read buffer, so that
1416 # if the raw seek fails, we don't lose buffered data forever.
1417 pos = self.raw.seek(pos, whence)
1418 with self._read_lock:
1419 self._reset_read_buf()
1420 if pos < 0:
1421 raise OSError("seek() returned invalid position")
1422 return pos
1423
1424 def tell(self):
1425 if self._write_buf:

Callers 1

Calls 4

lenFunction · 0.85
_reset_read_bufMethod · 0.80
flushMethod · 0.45
seekMethod · 0.45

Tested by 1