diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2024-05-05 21:32:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-05 21:32:23 +0200 |
commit | f27f8c790af1233d499b795af1c0d1b36aaecaf5 (patch) | |
tree | 22c502c6382512fafbb63e3020c8462e5400d4df /Lib/_pyrepl/trace.py | |
parent | 40cc809902304f60c6e1c933191dd4d64e570e28 (diff) | |
download | cpython-f27f8c790af1233d499b795af1c0d1b36aaecaf5.tar.gz cpython-f27f8c790af1233d499b795af1c0d1b36aaecaf5.zip |
gh-111201: A new Python REPL (GH-111567)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Lib/_pyrepl/trace.py')
-rw-r--r-- | Lib/_pyrepl/trace.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/_pyrepl/trace.py b/Lib/_pyrepl/trace.py new file mode 100644 index 00000000000..a8eb2433cd3 --- /dev/null +++ b/Lib/_pyrepl/trace.py @@ -0,0 +1,21 @@ +from __future__ import annotations + +import os + +# types +if False: + from typing import IO + + +trace_file: IO[str] | None = None +if trace_filename := os.environ.get("PYREPL_TRACE"): + trace_file = open(trace_filename, "a") + + +def trace(line: str, *k: object, **kw: object) -> None: + if trace_file is None: + return + if k or kw: + line = line.format(*k, **kw) + trace_file.write(line + "\n") + trace_file.flush() |