File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ objects so they can be GCed
2222
2323import (
2424 "fmt"
25+ "os"
2526 "runtime/debug"
2627 "strings"
2728
@@ -444,6 +445,12 @@ func do_DELETE_SUBSCR(vm *Vm, arg int32) error {
444445
445446// Miscellaneous opcodes.
446447
448+ // PrintExpr controls where the output of PRINT_EXPR goes which is
449+ // used in the REPL
450+ var PrintExpr = func (out string ) {
451+ _ , _ = os .Stdout .WriteString (out + "\n " )
452+ }
453+
447454// Implements the expression statement for the interactive mode. TOS
448455// is removed from the stack and printed. In non-interactive mode, an
449456// expression statement is terminated with POP_STACK.
@@ -460,7 +467,7 @@ func do_PRINT_EXPR(vm *Vm, arg int32) error {
460467 if err != nil {
461468 return err
462469 }
463- fmt .Printf ( "%s \n " , repr )
470+ PrintExpr ( fmt .Sprint ( repr ) )
464471 }
465472 vm .frame .Globals ["_" ] = value
466473 return nil
You can’t perform that action at this time.
0 commit comments