diff options
author | Tom Tromey <tromey@adacore.com> | 2022-08-15 12:45:43 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-08-30 11:49:48 -0600 |
commit | 2d83dd693901cb2588517d7296f1360d902c89f7 (patch) | |
tree | 32108cbc3abf6acf574a5b79fb0686aa446d8fe7 /gdb/python | |
parent | dd083c6524f1e90dae19ed895b3f5eaf6228de68 (diff) | |
download | gdb-2d83dd693901cb2588517d7296f1360d902c89f7.zip gdb-2d83dd693901cb2588517d7296f1360d902c89f7.tar.gz gdb-2d83dd693901cb2588517d7296f1360d902c89f7.tar.bz2 |
Fix flush for sys.stderr
GDB overwrites Python's sys.stdout and sys.stderr, but does not
properly implement the 'flush' method -- it only ever will flush
stdout. This patch fixes the bug. I couldn't find a straightforward
way to write a test for this.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/__init__.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 5b10e3e..191915e 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -39,6 +39,9 @@ class _GdbFile(object): encoding = "UTF-8" errors = "strict" + def __init__(self, stream): + self.stream = stream + def close(self): # Do nothing. return None @@ -51,23 +54,15 @@ class _GdbFile(object): self.write(line) def flush(self): - flush() - + flush(stream=self.stream) -class _GdbOutputFile(_GdbFile): def write(self, s): - write(s, stream=STDOUT) - + write(s, stream=self.stream) -sys.stdout = _GdbOutputFile() - - -class _GdbOutputErrorFile(_GdbFile): - def write(self, s): - write(s, stream=STDERR) +sys.stdout = _GdbFile(STDOUT) -sys.stderr = _GdbOutputErrorFile() +sys.stderr = _GdbFile(STDERR) # Default prompt hook does nothing. prompt_hook = None |