Skip to content

Commit c0f031f

Browse files
committed
Fix input assuming the last character being a '\n'
1 parent f2c7c0d commit c0f031f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/bltinmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,8 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
25862586
result = NULL;
25872587
}
25882588
else {
2589-
len--; /* strip trailing '\n' */
2589+
if (s[len-1] == '\n')
2590+
len--; /* strip trailing '\n' */
25902591
if (len != 0 && s[len-1] == '\r')
25912592
len--; /* strip trailing '\r' */
25922593
result = PyUnicode_Decode(s, len, stdin_encoding_str,

0 commit comments

Comments
 (0)