Skip to content

IDLE and Command line present different behavior for sys.stdin #53536

Closed

Description

@GeraldoXexeo
BPO 9290
Nosy @loewis, @terryjreedy, @kbkaiser, @taleinat, @serwy, @JimJJewett, @serhiy-storchaka
Files
  • idle_stdstreams-3.3.patch: Patch for 3.3 and 3.4
  • idle_stdstreams-3.2.patch: Patch for 3.2
  • idle_stdstreams-2.7.patch: Patch for 2.7
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2013-01-25.18:13:17.248>
    created_at = <Date 2010-07-18.01:51:33.535>
    labels = ['expert-IDLE', 'type-bug', 'expert-IO']
    title = 'IDLE and Command line present different behavior for sys.stdin'
    updated_at = <Date 2013-01-25.18:13:17.247>
    user = 'https://bugs.python.org/GeraldoXexeo'

    bugs.python.org fields:

    activity = <Date 2013-01-25.18:13:17.247>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2013-01-25.18:13:17.248>
    closer = 'serhiy.storchaka'
    components = ['IDLE', 'IO']
    creation = <Date 2010-07-18.01:51:33.535>
    creator = 'Geraldo.Xexeo'
    dependencies = []
    files = ['27518', '27519', '27520']
    hgrepos = []
    issue_num = 9290
    keywords = ['patch', 'needs review']
    message_count = 11.0
    messages = ['110621', '110904', '155389', '155951', '172595', '172685', '173072', '173084', '175744', '179988', '180586']
    nosy_count = 10.0
    nosy_names = ['loewis', 'terry.reedy', 'kbk', 'taleinat', 'roger.serwy', 'Geraldo.Xexeo', 'python-dev', 'Jim.Jewett', 'serhiy.storchaka', 'a']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9290'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    Activity

    1. GeraldoXexeo commented on Jul 18, 2010

      GeraldoXexeomannequin
      MannequinAuthor

      The fact that in IDLE sys.stdin is a idlelib.rpc.RPCProxy results in programs having different behavior in IDLE and in Command Line mode.

      I noticed that when grading many students exercises in IDLE. Things like:

      sys.stdin.readlines()

      just don´t exists in IDLE, but are fully operational in Command Line mode.

      In Command Line mode, sys.stdin is a file.

      This is expected, as the manual (27.1) says that sys.stdin (and stdout and stderrr) are "File objects corresponding to the interpreter’s standard input"

      There are also other "quirks".

      I fell that is really strange that stdin has different behavior for the same program.

    2. taleinat commented on Jul 20, 2010

      @taleinat
      Contributor

      I agree that the wrapping of these in IDLE should be as transparent as possible.

      It would be helpful if you could specify what other "quirks" you have found regarding sys.stdin, sys.stdout and sys.stderr, preferably describing use cases where these are problematic.

    3. a commented on Mar 11, 2012

      amannequin
      Mannequin

      Other quirks apparently caused by this bug:

      msvcrt.getch() does not block and wait for a keypress in IDLE. Returns immediately with b'\xff'.

      Some of the suggested usage in the manual for sys.stdin does not work under IDLE. E.g. sys.stdin.detach() doesn't work in IDLE. On this last point, the manual has a caveat in the last line of the sys.stdin description that could exonerate it. Regardless, the behavior is inconsistent and makes for awkward UI when using IDLE.

    4. jimjjewett commented on Mar 15, 2012

      jimjjewettmannequin
      Mannequin

      msvcrt.getwch has a similar failure, returning (2**16)-1.

      Because of this, getpass.win_getpass (used as getpass.getpass on windows) echoes the password when using Idle (even without a subprocess), but does not echo passwords when from a command-line python.

    5. serhiy-storchaka commented on Oct 10, 2012

      @serhiy-storchaka
      Member

      The proposed patches make the behavior of sys.std* files in IDLE more similar to the behavior of sys.std* files in standard interpreter. Now sys.stdin have read() and readlines() methods. The source code is simplified.

    6. serwy commented on Oct 11, 2012

      serwymannequin
      Mannequin

      I tried the patch for 3.3 and it works for me on Linux. It correctly handles prior issues like bpo-13532, bpo-15318, bpo-15319, and bpo-7163, as well as providing good support for .read, .readline, .readlines. Each of those methods respond correctly to Ctrl+C and Ctrl+D.

      On Windows 7, with 2.7.3, Ctrl+D is still needed to indicate end-of-file, instead of Ctrl+Z. This may or may not be significant, but it is related to bpo-14735.

    7. terryjreedy commented on Oct 16, 2012

      @terryjreedy
      Member

      I agree with the goal. We need an automated test for these proxies.

    8. serhiy-storchaka commented on Oct 16, 2012

      @serhiy-storchaka
      Member

      Unfortunately we have not a unittest framework for IDLE yet. After implementing bpo-15392 I will make tests for these proxies.

    9. serhiy-storchaka commented on Nov 17, 2012

      @serhiy-storchaka
      Member

      Since all previous changes were dispense with tests, I don't see why it should become an obstacle for this patch. Please review. This patch provides a simple and reliable solution for some other issues (mentioned in msg172685 issues and bpo-12967).

    10. serhiy-storchaka commented on Jan 14, 2013

      @serhiy-storchaka
      Member

      If no one objects, I'm going to commit this next week.

    11. python-dev commented on Jan 25, 2013

      python-devmannequin
      Mannequin

      New changeset def4cd7e0a9f by Serhiy Storchaka in branch '2.7':
      Issue bpo-9290: In IDLE the sys.std* streams now implement io.TextIOBase
      http://hg.python.org/cpython/rev/def4cd7e0a9f

      New changeset 0d26f3aa7a8f by Serhiy Storchaka in branch '3.2':
      Issue bpo-9290: In IDLE the sys.std* streams now implement io.TextIOBase
      http://hg.python.org/cpython/rev/0d26f3aa7a8f

      New changeset 9dfbd65d5041 by Serhiy Storchaka in branch '3.3':
      Issue bpo-9290: In IDLE the sys.std* streams now implement io.TextIOBase
      http://hg.python.org/cpython/rev/9dfbd65d5041

      New changeset 458b36fb12bc by Serhiy Storchaka in branch 'default':
      Issue bpo-9290: In IDLE the sys.std* streams now implement io.TextIOBase
      http://hg.python.org/cpython/rev/458b36fb12bc

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions