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 crashes when printing some unprintable characters. #57474

Closed
RamchandraApte mannequin opened this issue Oct 26, 2011 · 8 comments
Closed

IDLE crashes when printing some unprintable characters. #57474

RamchandraApte mannequin opened this issue Oct 26, 2011 · 8 comments

Comments

@RamchandraApte
Copy link
Mannequin

RamchandraApte mannequin commented Oct 26, 2011

BPO 13265
Nosy @kbkaiser, @ned-deily, @ezio-melotti, @serwy
Superseder
  • bpo-12342: characters with ord above 65535 fail to display in IDLE
  • Files
  • patch13265.diff
  • 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 2011-10-30.21:45:57.348>
    created_at = <Date 2011-10-26.05:48:48.777>
    labels = ['expert-IDLE']
    title = 'IDLE crashes when printing some unprintable characters.'
    updated_at = <Date 2011-10-30.21:45:57.347>
    user = 'https://bugs.python.org/RamchandraApte'

    bugs.python.org fields:

    activity = <Date 2011-10-30.21:45:57.347>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-10-30.21:45:57.348>
    closer = 'ned.deily'
    components = ['IDLE']
    creation = <Date 2011-10-26.05:48:48.777>
    creator = 'Ramchandra Apte'
    dependencies = []
    files = ['23561']
    hgrepos = []
    issue_num = 13265
    keywords = ['patch']
    message_count = 8.0
    messages = ['146411', '146412', '146413', '146414', '146415', '146448', '146652', '146662']
    nosy_count = 5.0
    nosy_names = ['kbk', 'ned.deily', 'ezio.melotti', 'roger.serwy', 'Ramchandra Apte']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '12342'
    type = None
    url = 'https://bugs.python.org/issue13265'
    versions = ['Python 3.2']

    @RamchandraApte
    Copy link
    Mannequin Author

    RamchandraApte mannequin commented Oct 26, 2011

    When you print an unprintable character, IDLE raises an error.
    >>> print(chr(500304)) # print an unprintable character
    The error is only visible when you run the code from a commmand-line.
    When you run python from the command-line and execute the code it shows
    the unprintable character symbol (looks like []).

    @RamchandraApte RamchandraApte mannequin added type-crash A hard crash of the interpreter, possibly with a core dump topic-IDLE labels Oct 26, 2011
    @RamchandraApte
    Copy link
    Mannequin Author

    RamchandraApte mannequin commented Oct 26, 2011

    Here's the Error message.
    *** Internal Error: rpc.py:SocketIO.localcall()

    Object: stdout
    Method: <bound method PseudoFile.write of <idlelib.PyShell.PseudoFile object at 0x2675550>>
    Args: ('\U0007a250',)

    Traceback (most recent call last):
      File "/usr/lib/python3.2/idlelib/rpc.py", line 188, in localcall
        ret = method(*args, **kwargs)
      File "/usr/lib/python3.2/idlelib/PyShell.py", line 1220, in write
        self.shell.write(s, self.tags)
      File "/usr/lib/python3.2/idlelib/PyShell.py", line 1202, in write
        OutputWindow.write(self, s, tags, "iomark")
      File "/usr/lib/python3.2/idlelib/OutputWindow.py", line 40, in write
        self.text.insert(mark, s, tags)
      File "/usr/lib/python3.2/idlelib/Percolator.py", line 25, in insert
        self.top.insert(index, chars, tags)
      File "/usr/lib/python3.2/idlelib/ColorDelegator.py", line 79, in insert
        self.delegate.insert(index, chars, tags)
      File "/usr/lib/python3.2/idlelib/PyShell.py", line 312, in insert
        UndoDelegator.insert(self, index, chars, tags)
      File "/usr/lib/python3.2/idlelib/UndoDelegator.py", line 81, in insert
        self.addcmd(InsertCommand(index, chars, tags))
      File "/usr/lib/python3.2/idlelib/UndoDelegator.py", line 116, in addcmd
        cmd.do(self.delegate)
      File "/usr/lib/python3.2/idlelib/UndoDelegator.py", line 219, in do
        text.insert(self.index1, self.chars, self.tags)
      File "/usr/lib/python3.2/idlelib/ColorDelegator.py", line 79, in insert
        self.delegate.insert(index, chars, tags)
      File "/usr/lib/python3.2/idlelib/WidgetRedirector.py", line 104, in __call__
        return self.tk_call(self.orig_and_operation + args)
    ValueError: unsupported character

    @RamchandraApte
    Copy link
    Mannequin Author

    RamchandraApte mannequin commented Oct 26, 2011

    My OS is Ubuntu Linux 11.10 (Oneiric Ocelot)
    Running uname -a gives "Linux ramcomputer 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux"

    @ezio-melotti
    Copy link
    Member

    Both print(chr(500304)) and print('\U0007a250') seem to work and print two empty boxes on IDLE with Python 3.2/WinXP.

    Is that error displayed in the IDLE window or does IDLE crash and you see the error somewhere else?

    @RamchandraApte
    Copy link
    Mannequin Author

    RamchandraApte mannequin commented Oct 26, 2011

    The error is visible from the command-line.

    @ned-deily
    Copy link
    Member

    With a current 3.3 build (i.e. "wide" build) on OS X, I can reproduce this. It causes an exception on the execution of that command in the IDLE shell but it doesn't crash IDLE. Not surprisingly, it doesn't seem to be reproducible with 3.2 "narrow" builds.

    @ned-deily ned-deily removed the type-crash A hard crash of the interpreter, possibly with a core dump label Oct 26, 2011
    @serwy
    Copy link
    Mannequin

    serwy mannequin commented Oct 30, 2011

    I can reproduce the problem with Ubuntu 11.04 with Python 3.2. The WidgetRedirector calls tk_call with a tuple containing unencoded Unicode strings.

    Attached is a patch to encode all arguments if the argument has the "encode" attribute. This seems to fix the problem, but can someone who knows more about Python and Tk's Unicode handling take a look?

    @ned-deily
    Copy link
    Member

    Sorry, I should have noticed earlier that this is a duplicate of bpo-12342. The problem is simply that Tcl/Tk does not currently support the display of Unicode code points outside of the BMP. The question then is what IDLE to do when asked to display such characters. The current behavior of letting tkinter detect the unsupported code point and bubbling up a somewhat unhelpful exception message is not the most user-friendly response. Let's continue any discussion of this over on the earlier issue.

    @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
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants