From effebe27f7059aef7462d55b15c05d91293dbbf9 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Fri, 19 Jul 2019 00:04:12 +0200 Subject: [PATCH 1/2] Simplifies _print_hex method Simplifies the `_print_hex` method. Note that there are ~4 different ways of implementing it: ``` In [1]: def a(x): ...: return hex(x).rstrip('L') ...: def b(x): ...: s = hex(x) ...: return s[0:-1] if s.endswith("L") else s ...: def c(x): ...: return '0x%x' % x ...: def d(x): ...: return '0x{:x}'.format(x) ``` --- pywraps/py_idaapi.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pywraps/py_idaapi.py b/pywraps/py_idaapi.py index 893e66d..cf25d3c 100644 --- a/pywraps/py_idaapi.py +++ b/pywraps/py_idaapi.py @@ -694,8 +694,7 @@ class IDAPython_displayhook: storage.append(str(item)) def _print_hex(self, x): - s = hex(x) - return s[0:-1] if s.endswith("L") else s + return hex(x).rstrip('L') def displayhook(self, item): if item is None or type(item) is bool: From 6e3899391a5916daea4d139c0500deb49d6c592f Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Fri, 5 May 2023 22:26:46 -0700 Subject: [PATCH 2/2] Update py_idaapi.py IDA 8 no longer supports Python 2. Therefore, in Python 3, no "L" suffix is generated. --- pywraps/py_idaapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywraps/py_idaapi.py b/pywraps/py_idaapi.py index cf25d3c..5605fb0 100644 --- a/pywraps/py_idaapi.py +++ b/pywraps/py_idaapi.py @@ -694,7 +694,7 @@ class IDAPython_displayhook: storage.append(str(item)) def _print_hex(self, x): - return hex(x).rstrip('L') + return hex(x) def displayhook(self, item): if item is None or type(item) is bool: