Skip to content

sys.stdin.readline 'unsupported' (IDLE 2.7.3, Win7, pythonw) #60307

Closed

Description

@terryjreedy
BPO 16103
Nosy @terryjreedy, @serwy, @serhiy-storchaka
Superseder
  • bpo-9290: IDLE and Command line present different behavior for sys.stdin
  • 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 = None
    closed_at = <Date 2012-10-17.00:13:45.662>
    created_at = <Date 2012-10-01.20:01:13.426>
    labels = ['expert-IDLE', 'type-bug', 'OS-windows']
    title = "sys.stdin.readline 'unsupported' (IDLE 2.7.3, Win7, pythonw)"
    updated_at = <Date 2012-10-17.00:13:45.661>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2012-10-17.00:13:45.661>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-10-17.00:13:45.662>
    closer = 'terry.reedy'
    components = ['IDLE', 'Windows']
    creation = <Date 2012-10-01.20:01:13.426>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 16103
    keywords = []
    message_count = 8.0
    messages = ['171743', '171766', '173022', '173028', '173029', '173044', '173073', '173111']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'roger.serwy', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'needs patch'
    status = 'closed'
    superseder = '9290'
    type = 'behavior'
    url = 'https://bugs.python.org/issue16103'
    versions = ['Python 2.7']

    Activity

    1. terryjreedy commented on Oct 1, 2012

      @terryjreedy
      MemberAuthor

      Problem is only 2.7.3 (not 3.2.3, 3.3.0), tested on Windows

      Command Line Window
      >>> help()
      ...
      help> _

      The _ is blinking, waiting for input.

      IDLE Shell
      >>> help()
      ...
      help> 
      Traceback (most recent call last):
        File "<pyshell#0>", line 1, in <module>
          help()
        File "C:\Programs\Python27\lib\site.py", line 467, in __call__
          return pydoc.help(*args, **kwds)
        File "C:\Programs\Python27\lib\pydoc.py", line 1750, in __call__
          self.interact()
        File "C:\Programs\Python27\lib\pydoc.py", line 1762, in interact
          request = self.getline('help> ')
        File "C:\Programs\Python27\lib\pydoc.py", line 1773, in getline
          return raw_input(prompt)
      UnsupportedOperation: readline

      There is no blinking _, at that is from the raw_input() call that failed. There is no problem with help() in IDLE for 3.2, 3.3.

      I see two possibilities:

      1. This has nothing to do with Idle directly, but is a problem with pythonw and raw_input/readline that was later fixed.
      2. This is a result of how stdin is proxied by Idle and that there is a difference between 2.7 and 3.x.

      builtin_raw_input in bltinmodule.c calls
      s = PyOS_Readline(PyFile_AsFile(fin), PyFile_AsFile(fout), prompt);
      and I presume PyOS_Readline eventually calls fin.readline()

      UnsupportedOperation is defined (in 2.7, at least) in _pyio.py
      _pyio._unsupported(self, name) raises it with names.
      That in turn is the default body for every operation. In particular,
      def readline(self):
      self._unsupported("readline")

      So I presume 2. is the problem and the proxy in the pythonw process is an io subclass that needs readline defined for help() to work.
      (Is proxying same on all OSes? Or would problem be Windows only?)

    2. serwy commented on Oct 2, 2012

      serwymannequin
      Mannequin

      Terry, I am unable to reproduce this error under Win7 Ultimate (no SP1) with either the 32-bit or 64-bit install of 2.7.3. Calling help() produces an interactive prompt in all my test cases. I launched IDLE from the start menu shortcut, with "python.exe -m idlelib.idle", and "pythonw.exe -m idlelib.idle".

      Running IDLE without a subprocess doesn't trigger the bug either.

      IDLE 2.7.3 works as well on Arch Linux with 2.7.3 (64-bit).

      (Also, I get a blinking vertical bar for the cursor, not an underscore on Win7. This minor detail is likely not relevant, only provided since it is an observed difference.)

      Does raw_input() work from a regular python shell for you?

    3. terryjreedy commented on Oct 16, 2012

      @terryjreedy
      MemberAuthor

      Yes, the first part of my post was about how it worked in regular interactive window: prints text, then prompt, then blinking underline cursor.

      Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32 -- Win7 Professional, with all MS patches.

      Are you running the apr 10 release or something compiled later, with the readline stub replaced?

      Problem manifests in raw_input(): get same behavior of print prompt then crash when should display input cursor.

      >>> raw_input('xyz')  # IDLE still
      xyz
      Traceback (most recent call last):
        File "<pyshell#1>", line 1, in <module>
          raw_input('xyz')
      UnsupportedOperation: readline

      Problem really is sys.stdin.readline(), which is the dummy stub I quoted in first message.

      >> sys.stdin.readline()

      Traceback (most recent call last):
        File "<pyshell#11>", line 1, in <module>
          sys.stdin.readline()
      UnsupportedOperation: readline
    4. changed the title [-]Help() fails at raw_input readline (IDLE 2.7.3, Win7, pythonw)[/-] [+]sys.stdin.readline 'unsupported' (IDLE 2.7.3, Win7, pythonw)[/+] on Oct 16, 2012
    5. serhiy-storchaka commented on Oct 16, 2012

      @serhiy-storchaka
      Member

      Check patch for bpo-9290.

    6. serhiy-storchaka commented on Oct 16, 2012

      @serhiy-storchaka
      Member

      What type of sys.stdin? Try run in "no subprocess" mode (-n).

    7. serwy commented on Oct 16, 2012

      serwymannequin
      Mannequin

      I am running 2.7.3 from Apr 10, 2012, freshly installed. I still can not reproduce this problem when running IDLE with or without a subprocess.

      Is your PyShell.py file the original or was it modified by accident? It may be possible that run.py was modified as well and is failing to register stdin correctly.

    8. terryjreedy commented on Oct 16, 2012

      @terryjreedy
      MemberAuthor

      Roger, you are partially right -- there are changes, but they were intentional. I updated the idlelib part of my installation to match the repository on July 9 to incorporate the _RPCFile wrapping of of the three stdio files, including this:

      •    sys.stdin = self.console = self.get_remote_proxy("stdin")
        

      + sys.stdin = self.console = _RPCFile(self.get_remote_proxy("stdin"))

      >>> import sys
      >>> sys.stdin
      <idlelib.run._RPCInputFile object at 0x000000000315D320>

      Sorry about forgetting this. Anyway, I presume you remember that issue. It seems that there is still a bug either in that update or its interaction with other code. What happens in linux with a fresh 2.7 build?

      Serhiy's patch for bpo-9290 replaces _RPCXyxFile with PseudoXyzFile subclasses of revised PseudoFile. If it works, it should fix this issue also.

    9. serwy commented on Oct 16, 2012

      serwymannequin
      Mannequin

      Terry, your idlelib directory is in an inconsistent state. IDLE 2.7.3 works well on Arch Linux. I rebuilt it from revision 70274d53c1dd. With and without a subprocess, IDLE's sys.stdin.readline works.

      Let's close this issue and focus on bpo-9290. It's your decision to close.

    10. 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

    Assignees

    No one assigned

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions