Skip to content

IDLE: system clear function returns 256 on Mac OS Catalina #83322

Closed

Description

@DavidTurner
BPO 39141
Nosy @terryjreedy, @ned-deily, @david Turner
Superseder
  • bpo-6143: IDLE - clear and restart the shell window
  • 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/terryjreedy'
    closed_at = <Date 2020-01-03.22:16:03.515>
    created_at = <Date 2019-12-27.18:15:59.649>
    labels = ['expert-IDLE', 'type-bug', '3.8']
    title = 'IDLE: system clear function returns 256 on Mac OS Catalina'
    updated_at = <Date 2020-01-03.22:16:03.511>
    user = 'https://github.com/DavidTurner'

    bugs.python.org fields:

    activity = <Date 2020-01-03.22:16:03.511>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2020-01-03.22:16:03.515>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2019-12-27.18:15:59.649>
    creator = 'twister68@gmail.com'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39141
    keywords = []
    message_count = 3.0
    messages = ['358908', '359022', '359261']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'ned.deily', 'twister68@gmail.com']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '6143'
    type = 'behavior'
    url = 'https://bugs.python.org/issue39141'
    versions = ['Python 3.8']

    Activity

    1. DavidTurner commented on Dec 27, 2019

      DavidTurnermannequin
      MannequinAuthor

      Trying to set up shortcut function to clear screen but its not working as expected on my Mac OS Catalina -- below is txt from idle

      import os
      >>> cls= lambda: os.system('clear')
      >>> cls()
      256
    2. ned-deily commented on Dec 30, 2019

      @ned-deily
      Member

      Unfortunately, this is not going to work as you expect because you are mixing commands for different windowing systems. The OS-level 'clear' command is used to clear a normal terminal window by issuing special character sequences to standard output that are recognized by the terminal emulator, like for instance Terminal.app on macOS. When you run commands using os.system() under IDLE on macOS, the standard output descriptor for the subprocess created by os.system is not handled by IDLE. Currently open bpo-11820 describes this problem. You are apparently running IDLE.app (by launching the app from the Finder) and the command fails because standard output of the subprocess is not associated with a terminal window. If, instead, you launched IDLE from a terminal window (in Terminal.app):

      /usr/local/bin/idle3.8

      and ran your test, you would see that the 'clear' clears the Terminal.app window, not the IDLE shell window (and now returns a status of 0), still not what you are looking for.

      Even if bpo-11820 is implemented such that the standard output from subprocesses are associated with the IDLE shell window, there would still be a problem in that the special character sequences sent by the 'clear' command would most likely not be recognized by the IDLE shell window or its underlying Tk widget, so using the OS 'clear' command still would not work. A better solution is for IDLE to provide its own 'clear' command and that is the subject of open bpo-6143, which this issue should probably be closed as a duplicate of.

    3. terryjreedy commented on Jan 3, 2020

      @terryjreedy
      Member

      Among other problems, the patch for bpo-11820 uses a unix-only tcl function.

      In non-shell editor and output windows, Select all (Control-A at least on windows) Delete (or Backspace, or Cut to clipboard, ^X on Windows) clears the window. Delete does not work for the read-only history portion of the Shell, hence the request for a separate menu item.

      However, if an editor window is open, one can still get a clean Shell by closing Shell and re-opening with Run => Shell or running the file being edited.

    4. changed the title [-]IDLE Clear function returns 256 on Mac OS Catalina[/-] [+]IDLE: system clear function returns 256 on Mac OS Catalina[/+] on Jan 3, 2020
    5. changed the title [-]IDLE Clear function returns 256 on Mac OS Catalina[/-] [+]IDLE: system clear function returns 256 on Mac OS Catalina[/+] on Jan 3, 2020
    6. 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

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions