From 730e41844aeb1185f97e98e3e6c739462a544e39 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sun, 10 Nov 2024 10:29:04 -0800 Subject: [PATCH] removed try/except, but keep the check on `tty` for api compat purpose --- gef.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gef.py b/gef.py index 20cea2914..f660408b6 100644 --- a/gef.py +++ b/gef.py @@ -3898,15 +3898,12 @@ def get_memory_alignment(in_bits: bool = False) -> int: def clear_screen(tty: str = "") -> None: """Clear the screen.""" - global gef + clean_sequence = "\x1b[H\x1b[J" + if tty: + pathlib.Path(tty).write_text(clean_sequence) + else: + sys.stdout.write(clean_sequence) - try: - sys.stdout.write("\x1b[H\x1b[J") - except PermissionError: - # Since the tty can be closed at any time, a PermissionError exception can - # occur when `clear_screen` is called. We handle this scenario properly - gef.ui.redirect_fd = None - gef.config["context.redirect"] = "" return