From acce2f4f070e6e3dedebc8e8f9b862165394057d Mon Sep 17 00:00:00 2001 From: Joe Ethier Date: Tue, 23 Jan 2018 12:28:48 -0800 Subject: [PATCH] Fix compatibility regression in inspector output module. (#706) * Fix compatibility regression in inspector output module. * Explicit version-specific branching. * Better Python3 compatibility approach. * Remove extraneous sys import. --- openhtf/output/callbacks/mfg_inspector.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openhtf/output/callbacks/mfg_inspector.py b/openhtf/output/callbacks/mfg_inspector.py index 0249bc525..4cf2e4c71 100644 --- a/openhtf/output/callbacks/mfg_inspector.py +++ b/openhtf/output/callbacks/mfg_inspector.py @@ -33,6 +33,10 @@ import os import threading import zlib +try: + from past.types import unicode +except ImportError: + pass import httplib2 import oauth2client.client @@ -155,8 +159,8 @@ def _extract_attachments(phase, testrun, used_parameter_names): name = _ensure_unique_parameter_name(name, used_parameter_names) testrun_param = testrun.info_parameters.add() testrun_param.name = name - if isinstance(attachment_data, str): - attachment_data = attachment_data.encode('utf8') + if isinstance(attachment_data, unicode): + attachment_data = attachment_data.encode('utf-8') testrun_param.value_binary = attachment_data if mimetype in MIMETYPE_MAP: testrun_param.type = MIMETYPE_MAP[mimetype]