From b5e86006a35910ff115d35998e84938e7d92a8ea Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 19 Mar 2019 22:04:55 -0400 Subject: Fix Python 2 issue in triage plugin --- python/examples/triage/byte.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'python/examples') diff --git a/python/examples/triage/byte.py b/python/examples/triage/byte.py index d4095237..f4a5056a 100644 --- a/python/examples/triage/byte.py +++ b/python/examples/triage/byte.py @@ -43,6 +43,12 @@ class ByteView(QAbstractScrollArea, View): u'≡', u'±', u'≥', u'≤', u'⌠', u'⌡', u'÷', u'≈', u'°', u'∙', u'·', u'√', u'ⁿ', u'²', u'■', u' ' ] + if sys.version_info.major == 2: + mapping = {} + for i in range(0, 256): + mapping[chr(i)] = self.byte_mapping[i] + self.byte_mapping = mapping + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setFocusPolicy(Qt.StrongFocus) @@ -508,7 +514,7 @@ class ByteView(QAbstractScrollArea, View): caretTextColor = self.palette().color(QPalette.Base) byteValue = self.data.read(lineStartAddr + cursorCol, 1) if len(byteValue) == 1: - byteStr = self.byte_mapping[ord(byteValue)] + byteStr = self.byte_mapping[byteValue[0]] render.drawText(p, 2 + (self.addrWidth + 2 + cursorCol) * charWidth, 2 + y * charHeight, caretTextColor, byteStr) def wheelEvent(self, event): -- cgit v1.3.1