Skip to content

Commit 83b8ec2

Browse files
committed
On input(..) use inputfun only if sys.stdin has not been overwritten.
1 parent 399aa8d commit 83b8ec2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/builtin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ Sk.builtin.raw_input = function (prompt) {
701701
var lprompt = prompt ? prompt : "";
702702

703703
return Sk.misceval.chain(Sk.importModule("sys", false, true), function (sys) {
704-
if (Sk.inputfunTakesPrompt) {
704+
const isTrueStdin = sys["$d"]["stdin"]["fileno"] == 0;
705+
if (Sk.inputfunTakesPrompt && isTrueStdin) {
705706
return Sk.builtin.file.$readline(sys["$d"]["stdin"], null, lprompt);
706707
} else {
707708
return Sk.misceval.chain(
@@ -791,7 +792,7 @@ Sk.builtin.exec = function (code, globals, locals) {
791792
);
792793
/**@todo shouldn't have to do this - Sk.globals loses scope*/
793794
const tmp = Sk.globals;
794-
/**
795+
/**
795796
* @todo this is not correct outside of __main__ i.e. exec doesn't work inside modules using the module scope
796797
* This is because globals don't work outside of __main__
797798
*/

0 commit comments

Comments
 (0)