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

Skip to content

Commit 299a734

Browse files
committed
Tighten error handling of string printing.
1 parent 2ba9f30 commit 299a734

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Python/ceval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,11 @@ eval_code(co, globals, locals, arg)
532532
char *s = getstringvalue(v);
533533
int len = getstringsize(v);
534534
fwrite(s, 1, len, fp);
535-
if (len > 0 && s[len-1] == '\n')
535+
if (ferror(fp)) {
536+
err_errno(IOError);
537+
err = -1;
538+
}
539+
else if (len > 0 && s[len-1] == '\n')
536540
softspace(sysget("stdout"), 0);
537541
}
538542
else {

0 commit comments

Comments
 (0)