Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01774be

Browse files
Arnaud DiederenArnaud Diederen
authored andcommitted
Backported fixes
1 parent 960d383 commit 01774be

4 files changed

Lines changed: 29 additions & 15 deletions

File tree

0 Bytes
Binary file not shown.

pydoc_injections2.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16921,7 +16921,8 @@ class Hexrays_Hooks(__builtin__.object)
1692116921
|
1692216922
| func_printed(self, *args)
1692316923
| Function text has been generated. Plugins may modify the text in
16924-
| 'cfunc_t::sv' .
16924+
| 'cfunc_t::sv' . The text uses regular color codes (see 'lines.hpp' )
16925+
| COLOR_ADDR is used to store pointers to ctree elements.
1692516926
|
1692616927
| func_printed(self, cfunc) -> int
1692716928
| @param cfunc (C++: cfunc_t *)
@@ -17102,9 +17103,9 @@ class Hexrays_Hooks(__builtin__.object)
1710217103
| Decompiled text is ready.
1710317104
|
1710417105
| text_ready(self, vu) -> int
17105-
| @param vu: This event can be used to modify the output text (sv). The
17106-
| text uses regular color codes (see lines.hpp) COLOR_ADDR is
17107-
| used to store pointers to ctree elements (C++: vdui_t *)
17106+
| @param vu: This event can be used to modify the output text (sv).
17107+
| Obsolete. Please use hxe_func_printed instead. (C++:
17108+
| vdui_t *)
1710817109
|
1710917110
| unhook(self, *args)
1711017111
| unhook(self) -> bool

pydoc_injections3.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16894,7 +16894,8 @@ class Hexrays_Hooks(builtins.object)
1689416894
|
1689516895
| func_printed(self, *args) -> 'int'
1689616896
| Function text has been generated. Plugins may modify the text in
16897-
| 'cfunc_t::sv' .
16897+
| 'cfunc_t::sv' . The text uses regular color codes (see 'lines.hpp' )
16898+
| COLOR_ADDR is used to store pointers to ctree elements.
1689816899
|
1689916900
| func_printed(self, cfunc) -> int
1690016901
| @param cfunc (C++: cfunc_t *)
@@ -17075,9 +17076,9 @@ class Hexrays_Hooks(builtins.object)
1707517076
| Decompiled text is ready.
1707617077
|
1707717078
| text_ready(self, vu) -> int
17078-
| @param vu: This event can be used to modify the output text (sv). The
17079-
| text uses regular color codes (see lines.hpp) COLOR_ADDR is
17080-
| used to store pointers to ctree elements (C++: vdui_t *)
17079+
| @param vu: This event can be used to modify the output text (sv).
17080+
| Obsolete. Please use hxe_func_printed instead. (C++:
17081+
| vdui_t *)
1708117082
|
1708217083
| unhook(self, *args) -> 'bool'
1708317084
| unhook(self) -> bool
@@ -17139,7 +17140,8 @@ class __cbhooks_t(Hexrays_Hooks)
1713917140
|
1714017141
| func_printed(self, *args)
1714117142
| Function text has been generated. Plugins may modify the text in
17142-
| 'cfunc_t::sv' .
17143+
| 'cfunc_t::sv' . The text uses regular color codes (see 'lines.hpp' )
17144+
| COLOR_ADDR is used to store pointers to ctree elements.
1714317145
|
1714417146
| func_printed(self, cfunc) -> int
1714517147
| @param cfunc (C++: cfunc_t *)
@@ -17215,9 +17217,9 @@ class __cbhooks_t(Hexrays_Hooks)
1721517217
| Decompiled text is ready.
1721617218
|
1721717219
| text_ready(self, vu) -> int
17218-
| @param vu: This event can be used to modify the output text (sv). The
17219-
| text uses regular color codes (see lines.hpp) COLOR_ADDR is
17220-
| used to store pointers to ctree elements (C++: vdui_t *)
17220+
| @param vu: This event can be used to modify the output text (sv).
17221+
| Obsolete. Please use hxe_func_printed instead. (C++:
17222+
| vdui_t *)
1722117223
|
1722217224
| ----------------------------------------------------------------------
1722317225
| Data and other attributes defined here:

pywraps/py_idaapi.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,20 @@ def IDAPython_ExecScript(script, g, print_error=True):
466466
g[FILE_ATTR] = script
467467

468468
try:
469-
with open(script) as fin:
470-
code = compile(fin.read(), script, 'exec')
471-
exec(code, g)
469+
with open(script, "rb") as fin:
470+
raw = fin.read()
471+
encoding = "UTF-8" # UTF-8 by default: https://www.python.org/dev/peps/pep-3120/
472+
473+
# Look for a 'coding' comment
474+
encoding_pat = re.compile(r'\s*#.*coding[:=]\s*([-\w.]+).*')
475+
for line in raw.decode("ASCII", errors='replace').split("\n"):
476+
match = encoding_pat.match(line)
477+
if match:
478+
encoding = match.group(1)
479+
break
480+
481+
code = compile(raw.decode(encoding), script, 'exec')
482+
exec(code, g)
472483
PY_COMPILE_ERR = None
473484
except Exception as e:
474485
PY_COMPILE_ERR = "%s\n%s" % (str(e), traceback.format_exc())

0 commit comments

Comments
 (0)