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

Method write_history_file

Lib/_pyrepl/readline.py:458–466  ·  view source on GitHub ↗
(self, filename: str = gethistoryfile())

Source from the content-addressed store, hash-verified

456 self.set_history_length(self.get_current_history_length())
457
458 def write_history_file(self, filename: str = gethistoryfile()) -> None:
459 maxlength = self.saved_history_length
460 history = self.get_reader().get_trimmed_history(maxlength)
461 f = open(os.path.expanduser(filename), "w",
462 encoding="utf-8", newline="\n")
463 with f:
464 for entry in history:
465 entry = entry.replace("\n", "\r\n") # multiline history support
466 f.write(entry + "\n")
467
468 def append_history_file(self, filename: str = gethistoryfile()) -> None:
469 reader = self.get_reader()

Callers 5

write_historyFunction · 0.80
test_nonascii_historyMethod · 0.80

Calls 7

get_readerMethod · 0.95
gethistoryfileFunction · 0.90
get_trimmed_historyMethod · 0.80
expanduserMethod · 0.80
openFunction · 0.50
replaceMethod · 0.45
writeMethod · 0.45