This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients kbk, ned.deily, roger.serwy, serhiy.storchaka, terry.reedy, tim.peters
Date 2013-11-04.06:55:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383548159.84.0.0302739780272.issue19481@psf.upfronthosting.co.za>
In-reply-to
Content
I am curious too, so I traced through the call chain.

In PyShell.py
1343: PseudoOutputFile.write(s) calls: self.shell.write(s, self.tags)
914: shell is an instance of PyShell and self.tags is 'stdout', 'stderr', or 'console'.
1291: PyShell.write(s,tags) calls:
 OutputWindow.write(self, s, tags, "iomark")
 (where 'iomark' must have been defined elsewhere, and the 'gravity' calls should not matter)

In OutputWindow.py
46: OutputWindow(EditorWindow).write(s,tags,mark='insert') calls: self.text.insert(mark, s, tags)
after trying to encode s if isinstance(s, str). It follows with:
        self.text.see(mark)
        self.text.update()
but if the insert succeeds, these should not care about the source of the inserted chars.

In EditorWindow.py
187: self.text = MultiCallCreator(Text)(text_frame, **text_options)
In MultiCall.py,
304: MultiCallCreator wraps a tk widget in a MultiCall instance that adds event methods but otherwise passes calls to the tk widget.

So PseudoOutputFile(s) becomes tk.Text().insert('iomark', s, 'stdout').
which becomes (lib-tk/tkinter.py, 3050)
  self.tk.call((self._w, 'insert', 'iomark', s) + args)

Tk handles either Latin-1 bytes or BMP unicode. It seems fine with a unicode subclass:
>>> import Tkinter as tk
>>> t = tk.Text()
>>> class F(unicode): pass

>>> f = F('foo')
>>> t.insert('1.0', u'abc', 'stdout') # 'iomark' is not defined
>>> t.insert('1.0', f, 'stdout')
>>> t.get('1.0', 'end')
u'abcfoo\n'

I remain puzzled.
History
Date User Action Args
2013-11-04 06:55:59terry.reedysetrecipients: + terry.reedy, tim.peters, kbk, ned.deily, roger.serwy, serhiy.storchaka
2013-11-04 06:55:59terry.reedysetmessageid: <1383548159.84.0.0302739780272.issue19481@psf.upfronthosting.co.za>
2013-11-04 06:55:59terry.reedylinkissue19481 messages
2013-11-04 06:55:58terry.reedycreate