Skip to content

Commit b369af9

Browse files
initial tracing for unic console
1 parent a4c9465 commit b369af9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pyrepl/trace.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
trace_filename = os.environ.get("PYREPL_TRACE")
4+
5+
if trace_filename is not None:
6+
trace_file = open(trace_filename, 'a')
7+
else:
8+
trace_file = None
9+
10+
def trace(line, *k, **kw):
11+
if trace_file is None:
12+
return
13+
if k or kw:
14+
line = line.format(*k, **kw)
15+
trace_file.write(line+'\n')
16+
trace_file.flush()
17+

pyrepl/unix_console.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .fancy_termios import tcgetattr, tcsetattr
2727
from .console import Console, Event
2828
from .unix_eventqueue import EventQueue
29+
from .trace import trace
2930

3031
class InvalidTerminal(RuntimeError):
3132
pass
@@ -410,6 +411,7 @@ def __sigwinch(self, signum, frame):
410411
self.event_queue.insert(Event('resize', None))
411412

412413
def push_char(self, char):
414+
trace('push char {char!r}', char=char)
413415
self.partial_char += char
414416
try:
415417
c = self.partial_char.decode(self.encoding)

0 commit comments

Comments
 (0)