Skip to content

Commit

Permalink
removed try/except, but keep the check on tty for api compat purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy authored Nov 10, 2024
1 parent a9930ea commit 730e418
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 730e418

Please sign in to comment.