<div dir="ltr">Can you leave the from __future__ import print_function at the top?  That's orthogonal to changing the dynamically executed code.<div><br></div><div>I can reproduce this problem by running LLDB in 2.7 and entering the embedded interpreter and typing print("foo", file=sys.stdout).  So I can probably fix that and this is an ok workaround for now, but people still need to be using print function instead of print statement on statically generated python code, so I think the future statement should stay.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 23, 2015 at 2:22 PM Siva Chandra <<a href="mailto:sivachandra@google.com">sivachandra@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sivachandra created this revision.<br>
sivachandra added a reviewer: zturner.<br>
sivachandra added a subscriber: lldb-commits.<br>
<br>
"from __future__ import print_function" was added to the test file but<br>
not to the embedded interpreter. This change uses file.write instead to<br>
avoid all problems with print.<br>
<br>
<a href="http://reviews.llvm.org/D14029" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14029</a><br>
<br>
Files:<br>
  test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py<br>
<br>
Index: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py<br>
===================================================================<br>
--- test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py<br>
+++ test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py<br>
@@ -2,8 +2,6 @@<br>
 Test lldb breakpoint command add/list/delete.<br>
 """<br>
<br>
-from __future__ import print_function<br>
-<br>
 import lldb_shared<br>
<br>
 import os, time<br>
@@ -52,7 +50,7 @@<br>
<br>
         # Now add callbacks for the breakpoints just created.<br>
         self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4")<br>
-        self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print(\"lldb\", file=here); here.close()' 2")<br>
+        self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2")<br>
         self.runCmd("breakpoint command add --python-function bktptcmd.function 3")<br>
<br>
         # Check that the breakpoint commands are correctly set.<br>
@@ -74,7 +72,7 @@<br>
         self.expect("breakpoint command list 2", "Breakpoint 2 command ok",<br>
             substrs = ["Breakpoint commands:",<br>
                           "here = open",<br>
-                          "print(file=here)",<br>
+                          "here.write",<br>
                           "here.close()"])<br>
         self.expect("breakpoint command list 3", "Breakpoint 3 command ok",<br>
             substrs = ["Breakpoint commands:",<br>
@@ -178,7 +176,7 @@<br>
         lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)<br>
<br>
         # Now add callbacks for the breakpoints just created.<br>
-        self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); print(frame, file=here); print(bp_loc, file=here); here.close()' 1")<br>
+        self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); here.write(str(frame) + \"\\n\"); here.write(str(bp_loc) + \"\\n\"); here.close()' 1")<br>
<br>
         # Remove 'output-2.txt' if it already exists.<br>
<br>
<br>
<br>
</blockquote></div>