classification
Title: stdin.readline behaviour different between IDLE and the console
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7, Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: jason.briggs, serhiy.storchaka
Priority: normal Keywords:

Created on 2013-02-20 11:45 by jason.briggs, last changed 2013-02-20 12:45 by serhiy.storchaka. This issue is now closed.

Messages (3)
msg182488 - (view) Author: Jason R Briggs (jason.briggs) Date: 2013-02-20 11:45
The sys.stdin.readline function takes a limit parameter, which limits the number of characters read. If you try using that parameter in IDLE, you get the following error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    sys.stdin.readline(13)
TypeError: readline() takes exactly 1 positional argument (2 given)

I've tried this in a number of different versions and it looks to have been like this for a while. A possible fix looks fairly straightforward. Something vaguely like...

<     def readline(self):
---
>     def readline(self, limit=-1):
993a994,995
>         if limit >= 0:
>             line = line[0:limit]

(with apologies if this is a dup ticket -- there seems to be a number of tickets raised regarding issues with IDLE and its version stdin/stdout, but I couldn't see any which discussed this particular behaviour).
msg182490 - (view) Author: Jason R Briggs (jason.briggs) Date: 2013-02-20 11:50
Note, that change I quoted would be in idlelib/PyShell.py
msg182500 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-20 12:45
Already fixed in issue9290.
History
Date User Action Args
2013-02-20 12:45:37serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg182500

resolution: out of date
stage: resolved
2013-02-20 11:50:56jason.briggssetmessages: + msg182490
2013-02-20 11:45:29jason.briggscreate