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

Skip to content

Commit 0fd5576

Browse files
Issue #20058: sys.stdin.readline() in IDLE now always returns only one line.
1 parent f47036c commit 0fd5576

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/idlelib/PyShell.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,9 @@ def readline(self, size=-1):
13811381
line = self._line_buffer or self.shell.readline()
13821382
if size < 0:
13831383
size = len(line)
1384+
eol = line.find('\n', 0, size)
1385+
if eol >= 0:
1386+
size = eol + 1
13841387
self._line_buffer = line[size:]
13851388
return line[:size]
13861389

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ Library
169169
IDLE
170170
----
171171

172+
- Issue #20058: sys.stdin.readline() in IDLE now always returns only one line.
173+
172174
- Issue #19481: print() of string subclass instance in IDLE no longer hangs.
173175

174176
- Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial

0 commit comments

Comments
 (0)