From 8717510d3561c403beb235996bf4c910da0c55d0 Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Thu, 3 Oct 2019 15:16:28 +0500 Subject: [PATCH] BOM-805 python3 compatibility: Before comparison with unicode decode text if its type is bytes. --- common/lib/capa/capa/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/capa/util.py b/common/lib/capa/capa/util.py index 2b700e4c18..0dfc955c19 100644 --- a/common/lib/capa/capa/util.py +++ b/common/lib/capa/capa/util.py @@ -4,6 +4,7 @@ Utility functions for capa. from __future__ import absolute_import import re +import six from cmath import isinf, isnan from decimal import Decimal @@ -117,7 +118,7 @@ def contextualize_text(text, context): # private # Should be a separate dict of variables that should be # replaced. context_key = '$' + key - if context_key in text: + if context_key in (text.decode('utf-8') if six.PY3 and isinstance(text, bytes) else text): text = convert_to_str(text) context_value = convert_to_str(context[key]) text = text.replace(context_key, context_value)