Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GeraldoXexeo mannequin opened this issue Jul 18, 2010 · 11 comments
Closed

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

GeraldoXexeo mannequin opened this issue Jul 18, 2010 · 11 comments
Assignees
Labels
topic-IDLE topic-IO type-bug An unexpected behavior, bug, or error

Comments

@GeraldoXexeo
Copy link
Mannequin

GeraldoXexeo mannequin commented Jul 18, 2010

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']

    @GeraldoXexeo
    Copy link
    Mannequin Author

    GeraldoXexeo mannequin commented Jul 18, 2010

    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.

    @taleinat
    Copy link
    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.

    @a
    Copy link
    Mannequin

    a mannequin commented Mar 11, 2012

    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.

    @jimjjewett
    Copy link
    Mannequin

    jimjjewett mannequin commented Mar 15, 2012

    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.

    @serhiy-storchaka
    Copy link
    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.

    @serwy
    Copy link
    Mannequin

    serwy mannequin commented Oct 11, 2012

    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.

    @terryjreedy
    Copy link
    Member

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

    @serhiy-storchaka
    Copy link
    Member

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

    @serhiy-storchaka
    Copy link
    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).

    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Nov 17, 2012
    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 27, 2012
    @serhiy-storchaka
    Copy link
    Member

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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 25, 2013

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-IDLE topic-IO type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants