Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit d7bacfa

Browse files
author
cclauss
committed
Modernize Python 2 code to get ready for Python 3
1 parent 701bb1b commit d7bacfa

83 files changed

Lines changed: 398 additions & 323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Scripts/3rd/BboeVt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Modified by Elias Bachaalany <elias at hex-rays.com>
55
66
"""
7+
from __future__ import print_function
78

89
import hashlib, httplib, mimetypes, os, pprint, simplejson, sys, urlparse
910

Scripts/AsmViewer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# -----------------------------------------------------------------------
23
# This is an example illustrating how to use customview in Python
34
# The sample will allow you to open an assembly file and display it in color
@@ -192,9 +193,9 @@ def OnKeydown(self, vkey, shift):
192193
self.ClearLines()
193194
self.Refresh()
194195
elif vkey == ord('S'):
195-
print "Selection (x1, y1, x2, y2) = ", self.GetSelection()
196+
print("Selection (x1, y1, x2, y2) = ", self.GetSelection())
196197
elif vkey == ord('I'):
197-
print "Position (line, x, y) = ", self.GetPos(mouse = 0)
198+
print("Position (line, x, y) = ", self.GetPos(mouse = 0))
198199
else:
199200
return False
200201
return True

Scripts/CallStackWalk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __str__(self):
107107
sp = idautils.cpu.Esp - word_size
108108
while sp < stack_seg.end_ea:
109109
sp += word_size
110-
ptr = idautils.GetDataList(sp, 1, word_size).next()
110+
ptr = next(idautils.GetDataList(sp, 1, word_size))
111111
seg = ida_segment.getseg(ptr)
112112
# only accept executable segments
113113
if (not seg) or ((seg.perm & ida_segment.SEGPERM_EXEC) == 0):

Scripts/DbgCmd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# -----------------------------------------------------------------------
23
# Debugger command prompt with CustomViewers
34
# (c) Hex-Rays
@@ -96,7 +97,7 @@ def ResetOutput(self):
9697
def show_win():
9798
x = dbgcmd_t()
9899
if not x.Create():
99-
print "Failed to create debugger command line!"
100+
print("Failed to create debugger command line!")
100101
return None
101102
x.Show()
102103

Scripts/DrvsDispatch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ALL RIGHTS RESERVED.
77
88
"""
9+
from __future__ import print_function
910

1011
import re
1112

@@ -54,7 +55,7 @@ def GetDriverDispatch():
5455

5556
# force reloading of module symbols
5657
if not CmdReloadForce():
57-
print "Could not communicate with WinDbg, make sure the debugger is running!"
58+
print("Could not communicate with WinDbg, make sure the debugger is running!")
5859
return None
5960

6061
# get driver list
@@ -75,7 +76,7 @@ def GetDriverDispatch():
7576
tbl_out = CmdDrvObj(drvname)
7677

7778
if not tbl_out:
78-
print "Failed to get driver object for", drvname
79+
print("Failed to get driver object for", drvname)
7980
continue
8081

8182
# for each line
@@ -116,4 +117,4 @@ def OnSelectLine(self, n):
116117
c = DispatchChoose("Dispatch table browser", r)
117118
c.Show(True)
118119
else:
119-
print "Failed to retrieve dispatchers list!"
120+
print("Failed to retrieve dispatchers list!")

Scripts/ExchainDump.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ALL RIGHTS RESERVED.
77
88
"""
9+
from __future__ import print_function
910

1011
import re
1112

@@ -51,4 +52,4 @@ def main():
5152

5253
ok, r = main()
5354
if not ok:
54-
print r
55+
print(r)

Scripts/FindInstructions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Copyright (c) 1990-2018 Hex-Rays
1717
ALL RIGHTS RESERVED.
1818
"""
19+
from __future__ import print_function
1920
import re
2021

2122
import ida_idaapi
@@ -73,7 +74,7 @@ def FindInstructions(instr, asm_where=None):
7374
bin_str = ' '.join(["%02X" % ord(x) for x in buf])
7475

7576
# find all binary strings
76-
print "Searching for: [%s]" % bin_str
77+
print("Searching for: [%s]" % bin_str)
7778
ea = ida_ida.cvar.inf.min_ea
7879
ret = []
7980
while True:
@@ -154,7 +155,7 @@ def find(s=None, x=False, asm_where=None):
154155
c = SearchResultChoose(title, results)
155156
c.Show(True)
156157
else:
157-
print ret
158+
print(ret)
158159

159160
# -----------------------------------------------------------------------
160-
print "Please use find('asm_stmt1;xx yy;...', x=Bool,asm_where=ea) to search for instructions or opcodes. Specify x=true to filter out non-executable segments"
161+
print("Please use find('asm_stmt1;xx yy;...', x=Bool,asm_where=ea) to search for instructions or opcodes. Specify x=true to filter out non-executable segments")

Scripts/ImpRef.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# -----------------------------------------------------------------------
23
# This is an example illustrating how to enumerate all addresses
34
# that refer to all imported functions in a given module
@@ -47,7 +48,7 @@ def find_import_ref(dllname):
4748
continue
4849

4950
# save results
50-
if not R.has_key(i):
51+
if i not in R:
5152
R[i] = []
5253

5354
R[i].append(ea)

Scripts/ImportExportViewer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# -----------------------------------------------------------------------
23
# This is an example illustrating how to:
34
# - enumerate imports
@@ -100,7 +101,7 @@ def OnClose(self, form):
100101
"""
101102
global ImpExpForm
102103
del ImpExpForm
103-
print "Closed"
104+
print("Closed")
104105

105106

106107
def Show(self):

Scripts/PteDump.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12

23
import ida_kernwin
34
import ida_segment

0 commit comments

Comments
 (0)