Skip to content

Commit a5ddc67

Browse files
committed
use PYTHONBIN across the source
1 parent 590f2b9 commit a5ddc67

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

gef.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5960,8 +5960,6 @@ def set_fs(uc, addr): return set_msr(uc, FSMSR, addr)
59605960
set_gs(emu, SEGMENT_GS_ADDR)
59615961
"""
59625962

5963-
pythonbin = which("python3")
5964-
59655963
content = """#!{pythonbin} -i
59665964
#
59675965
# Emulation script for "{fname}" from {start:#x} to {end:#x}
@@ -6016,7 +6014,7 @@ def reset():
60166014
emu = unicorn.Uc({arch}, {mode})
60176015
60186016
{context_block}
6019-
""".format(pythonbin=pythonbin, fname=fname, start=start_insn_addr, end=end_insn_addr,
6017+
""".format(pythonbin=PYTHONBIN, fname=fname, start=start_insn_addr, end=end_insn_addr,
60206018
regs=",".join(["'%s': %s" % (k.strip(), unicorn_registers[k]) for k in unicorn_registers]),
60216019
verbose="True" if verbose else "False",
60226020
syscall_reg=current_arch.syscall_register,
@@ -6105,8 +6103,7 @@ def emulate(emu, start_addr, end_addr):
61056103

61066104
ok("Starting emulation: {:#x} {} {:#x}".format(start_insn_addr, RIGHT_ARROW, end_insn_addr))
61076105

6108-
pythonbin = which("python3")
6109-
res = gef_execute_external([pythonbin, tmp_filename], as_list=True)
6106+
res = gef_execute_external([PYTHONBIN, tmp_filename], as_list=True)
61106107
gef_print("\n".join(res))
61116108

61126109
if not kwargs.get("to_file", None):
@@ -10681,11 +10678,11 @@ def __gef_prompt__(current_prompt):
1068110678
# In order to fix it, from the shell with venv activated we run the python binary,
1068210679
# take and parse its path, add the path to the current python process using sys.path.extend
1068310680

10684-
pythonbin = which("python3")
10685-
PREFIX = gef_pystring(subprocess.check_output([pythonbin, '-c', 'import os, sys;print((sys.prefix))'])).strip("\\n")
10681+
PYTHONBIN = which("python3")
10682+
PREFIX = gef_pystring(subprocess.check_output([PYTHONBIN, '-c', 'import os, sys;print((sys.prefix))'])).strip("\\n")
1068610683
if PREFIX != sys.base_prefix:
1068710684
SITE_PACKAGES_DIRS = subprocess.check_output(
10688-
[pythonbin, "-c", "import os, sys;print(os.linesep.join(sys.path).strip())"]).decode("utf-8").split()
10685+
[PYTHONBIN, "-c", "import os, sys;print(os.linesep.join(sys.path).strip())"]).decode("utf-8").split()
1068910686
sys.path.extend(SITE_PACKAGES_DIRS)
1069010687

1069110688
# setup prompt

0 commit comments

Comments
 (0)