File tree 1 file changed +8
-1
lines changed
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
22
22
23
23
import (
24
24
"fmt"
25
+ "os"
25
26
"runtime/debug"
26
27
"strings"
27
28
@@ -444,6 +445,12 @@ func do_DELETE_SUBSCR(vm *Vm, arg int32) error {
444
445
445
446
// Miscellaneous opcodes.
446
447
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
+
447
454
// Implements the expression statement for the interactive mode. TOS
448
455
// is removed from the stack and printed. In non-interactive mode, an
449
456
// expression statement is terminated with POP_STACK.
@@ -460,7 +467,7 @@ func do_PRINT_EXPR(vm *Vm, arg int32) error {
460
467
if err != nil {
461
468
return err
462
469
}
463
- fmt .Printf ( "%s \n " , repr )
470
+ PrintExpr ( fmt .Sprint ( repr ) )
464
471
}
465
472
vm .frame .Globals ["_" ] = value
466
473
return nil
You can’t perform that action at this time.
0 commit comments