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

Method seek

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

Source from the content-addressed store, hash-verified

969 return n
970
971 def seek(self, pos, whence=0):
972 if self.closed:
973 raise ValueError("seek on closed file")
974 try:
975 pos_index = pos.__index__
976 except AttributeError:
977 raise TypeError(f"{pos!r} is not an integer")
978 else:
979 pos = pos_index()
980 if whence == 0:
981 if pos < 0:
982 raise ValueError("negative seek position %r" % (pos,))
983 self._pos = pos
984 elif whence == 1:
985 with self._lock:
986 self._pos = max(0, self._pos + pos)
987 elif whence == 2:
988 with self._lock:
989 self._pos = max(0, len(self._buffer) + pos)
990 else:
991 raise ValueError("unsupported whence value")
992 return self._pos
993
994 def tell(self):
995 if self.closed:

Callers 15

mainFunction · 0.95
_dump_messageMethod · 0.95
_install_messageMethod · 0.95
_safe_readMethod · 0.95
list_directoryMethod · 0.95
dumpsMethod · 0.95
dumpsMethod · 0.95
check_file_digestMethod · 0.95
test_storbinaryMethod · 0.95
test_storbinary_restMethod · 0.95
test_file_dictMethod · 0.95

Calls

no outgoing calls

Tested by 15

dumpsMethod · 0.76
dumpsMethod · 0.76
check_file_digestMethod · 0.76
test_storbinaryMethod · 0.76
test_storbinary_restMethod · 0.76
test_file_dictMethod · 0.76
test_file_prefixMethod · 0.76
test_open_dictMethod · 0.76
test_open_prefixMethod · 0.76
send_typical_requestMethod · 0.76