Re: [Lldb-commits] [PATCH] D14029: [TestBreakpointCommand] Fix after r251121
sivachandra updated this revision to Diff 38265. sivachandra added a comment. Put back the import of print_function from __future__. http://reviews.llvm.org/D14029 Files: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Index: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py === --- test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -52,7 +52,7 @@ # Now add callbacks for the breakpoints just created. self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") -self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print(\"lldb\", file=here); here.close()' 2") +self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") self.runCmd("breakpoint command add --python-function bktptcmd.function 3") # Check that the breakpoint commands are correctly set. @@ -74,7 +74,7 @@ self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs = ["Breakpoint commands:", "here = open", - "print(file=here)", + "here.write", "here.close()"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs = ["Breakpoint commands:", @@ -178,7 +178,7 @@ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. -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") +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") # Remove 'output-2.txt' if it already exists. Index: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py === --- test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -52,7 +52,7 @@ # Now add callbacks for the breakpoints just created. self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") -self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print(\"lldb\", file=here); here.close()' 2") +self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") self.runCmd("breakpoint command add --python-function bktptcmd.function 3") # Check that the breakpoint commands are correctly set. @@ -74,7 +74,7 @@ self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs = ["Breakpoint commands:", "here = open", - "print(file=here)", + "here.write", "here.close()"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs = ["Breakpoint commands:", @@ -178,7 +178,7 @@ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. -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") +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") # Remove 'output-2.txt' if it already exists. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D14029: [TestBreakpointCommand] Fix after r251121
Can you leave the from __future__ import print_function at the top? That's orthogonal to changing the dynamically executed code. 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. On Fri, Oct 23, 2015 at 2:22 PM Siva Chandra wrote: > sivachandra created this revision. > sivachandra added a reviewer: zturner. > sivachandra added a subscriber: lldb-commits. > > "from __future__ import print_function" was added to the test file but > not to the embedded interpreter. This change uses file.write instead to > avoid all problems with print. > > http://reviews.llvm.org/D14029 > > Files: > > test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py > > Index: > test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py > === > --- > test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py > +++ > test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py > @@ -2,8 +2,6 @@ > Test lldb breakpoint command add/list/delete. > """ > > -from __future__ import print_function > - > import lldb_shared > > import os, time > @@ -52,7 +50,7 @@ > > # Now add callbacks for the breakpoints just created. > self.runCmd("breakpoint command add -s command -o 'frame variable > --show-types --scope' 1 4") > -self.runCmd("breakpoint command add -s python -o 'here = > open(\"output.txt\", \"w\"); print(\"lldb\", file=here); here.close()' 2") > +self.runCmd("breakpoint command add -s python -o 'here = > open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") > self.runCmd("breakpoint command add --python-function > bktptcmd.function 3") > > # Check that the breakpoint commands are correctly set. > @@ -74,7 +72,7 @@ > self.expect("breakpoint command list 2", "Breakpoint 2 command > ok", > substrs = ["Breakpoint commands:", >"here = open", > - "print(file=here)", > + "here.write", >"here.close()"]) > self.expect("breakpoint command list 3", "Breakpoint 3 command > ok", > substrs = ["Breakpoint commands:", > @@ -178,7 +176,7 @@ > lldbutil.run_break_set_by_file_and_line (self, "main.c", > self.line, num_expected_locations=1, loc_exact=True) > > # Now add callbacks for the breakpoints just created. > -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") > +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") > > # Remove 'output-2.txt' if it already exists. > > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D14029: [TestBreakpointCommand] Fix after r251121
sivachandra created this revision. sivachandra added a reviewer: zturner. sivachandra added a subscriber: lldb-commits. "from __future__ import print_function" was added to the test file but not to the embedded interpreter. This change uses file.write instead to avoid all problems with print. http://reviews.llvm.org/D14029 Files: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Index: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py === --- test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -2,8 +2,6 @@ Test lldb breakpoint command add/list/delete. """ -from __future__ import print_function - import lldb_shared import os, time @@ -52,7 +50,7 @@ # Now add callbacks for the breakpoints just created. self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") -self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print(\"lldb\", file=here); here.close()' 2") +self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") self.runCmd("breakpoint command add --python-function bktptcmd.function 3") # Check that the breakpoint commands are correctly set. @@ -74,7 +72,7 @@ self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs = ["Breakpoint commands:", "here = open", - "print(file=here)", + "here.write", "here.close()"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs = ["Breakpoint commands:", @@ -178,7 +176,7 @@ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. -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") +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") # Remove 'output-2.txt' if it already exists. Index: test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py === --- test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -2,8 +2,6 @@ Test lldb breakpoint command add/list/delete. """ -from __future__ import print_function - import lldb_shared import os, time @@ -52,7 +50,7 @@ # Now add callbacks for the breakpoints just created. self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") -self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print(\"lldb\", file=here); here.close()' 2") +self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") self.runCmd("breakpoint command add --python-function bktptcmd.function 3") # Check that the breakpoint commands are correctly set. @@ -74,7 +72,7 @@ self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs = ["Breakpoint commands:", "here = open", - "print(file=here)", + "here.write", "here.close()"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs = ["Breakpoint commands:", @@ -178,7 +176,7 @@ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. -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") +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") # Remove 'output-2.txt' if it already exists. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits