From 18270a843a959d5a2cc02daf15caa00dbc350f73 Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Mon, 14 Nov 2016 23:53:45 +0000 Subject: [PATCH] Fix TestMiniDumpNew.py test for Python 2/3 issue On Windows, where we use Python 3 for testing, we have to be more explicit about converting between binary and string representations. I believe this should still work for Python 2, but I don't have a convenient way to try it out. Differential Revision: https://reviews.llvm.org/D26643 llvm-svn: 286909 --- .../postmortem/minidump-new/TestMiniDumpNew.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 4691b019097b..44a42fdfe9d1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -108,15 +108,16 @@ class MiniDumpNewTestCase(TestBase): /proc/PID/status which is written in the file """ shutil.copyfile(core, newcore) - with open(newcore, "r+") as f: + with open(newcore, "rb+") as f: f.seek(offset) - self.assertEqual(f.read(5), oldpid) + currentpid = f.read(5).decode('utf-8') + self.assertEqual(currentpid, oldpid) f.seek(offset) if len(newpid) < len(oldpid): newpid += " " * (len(oldpid) - len(newpid)) newpid += "\n" - f.write(newpid) + f.write(newpid.encode('utf-8')) def test_deeper_stack_in_minidump_with_same_pid_running(self): """Test that we read the information from the core correctly even if we