Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22ebe2f

Browse files
committed
Strip leading whitespace from input().
1 parent 27aaa6d commit 22ebe2f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Python/bltinmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ builtin_input(self, v)
317317
FILE *out = sysgetfile("stdout", stdout);
318318
node *n;
319319
int err;
320+
int c;
320321
object *m, *d;
321322
flushline();
322323
if (v != NULL) {
@@ -325,6 +326,9 @@ builtin_input(self, v)
325326
}
326327
m = add_module("__main__");
327328
d = getmoduledict(m);
329+
while ((c = getc(in)) != EOF && (c == ' ' || c == '\t'))
330+
;
331+
ungetc(c, in);
328332
return run_file(in, "<stdin>", expr_input, d, d);
329333
}
330334

0 commit comments

Comments
 (0)