[Patches] [ python-Patches-520483 ] Make IDLE OutputWindow handle Unicode

noreply@sourceforge.net noreply@sourceforge.net
Thu, 28 Feb 2002 14:59:39 -0800


Patches item #520483, was opened at 2002-02-20 09:58
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=520483&group_id=5470

Category: IDLE
Group: Python 2.2.x
>Status: Closed
Resolution: Accepted
Priority: 7
Submitted By: Jason Orendorff (jorend)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Make IDLE OutputWindow handle Unicode

Initial Comment:
This one-line patch makes OutputWindow handle
Unicode correctly.  For example,

  >>> print u'\xbfQu\xe9 pas\xf3?'

In 2.2 this throws a UnicodeError,
not because of any problem with Unicode
handling in either Python or Tk, but
because IDLE does str(s) on the Unicode
string.

I just took out the call to str().


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-02-28 17:59

Message:
Logged In: YES 
user_id=6380

I think when I first wrote that code, Tkinter didn't yet
support Unicode. I think I felt that write() shouldn't be
called with anything besides a string, but I didn't want to
put in an explicit type check, and yet I didn't want to pass
non-strings to Tcl because it treats certain types special.
For example, in the patched IDLE, try
sys.stdout.write((1,2,(3,4))), or try
sys.stdout.write(None).

But I think it's no big deal, and I approve of the change.
Consequently, I'm closing this bug report again. I've merged
this into 2.2.1. Should I do anything else?

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-02-23 19:43

Message:
Logged In: YES 
user_id=31435

We're never too busy for people we love, Jason <wink>.

Reopened, changed category to IDLE, changed group to Python 
2.2.x, boosted priority, and assigned to Guido.

The str() call has been there since Guido first checked 
this in, and its purpose isn't apparent to me either.  
Maybe Guido remembers.  Guido?

I'm not worried at all that someone might be calling it 
with a non-stringish argument -- it's supplying a "file-
like object" interface, and .write() requires a stringish 
argument.

----------------------------------------------------------------------

Comment By: Jason Orendorff (jorend)
Date: 2002-02-23 19:19

Message:
Logged In: YES 
user_id=18139

Submitted to idlefork.

I'm too shy to bother "one of the major IDLE authors."  It 
would be nice to have in 2.2.1, but I know the folks at 
PythonLabs are busy...

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-02-23 17:42

Message:
Logged In: YES 
user_id=21627

Ok, committed as OutputWindow 1.6. I strongly recommend to
submit this to idlefork as well. If want this patch to
appear in Python 2.2.1, you should get a comment from one of
the major IDLE authors or contributors.

----------------------------------------------------------------------

Comment By: Jason Orendorff (jorend)
Date: 2002-02-20 18:27

Message:
Logged In: YES 
user_id=18139

> Isn't this too simplistic? I guess there was a reason for
> the str call: could it ever happen that somebody passes
> something else (beyond byte and Unicode strings)?

I searched for write() in the idle directory and got
48 hits in 7 files.  Then I checked them all.  In every
case, either write() is called with a string, or the
argument is passed unchanged from another function that
contains the word "write()".

As for code outside IDLE, I'd be extra surprised if
anyone calls obj.write(x) with x being something other
than a string.  Ordinary file objects don't accept it.


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-02-20 17:56

Message:
Logged In: YES 
user_id=21627

Isn't this too simplistic? I guess there was a reason for
the str call: could it ever happen that somebody passes
something else (beyond byte and Unicode strings)?

Also, I wonder whether IDLE patches need to go to idlefork
(sf.net/projects/idlefork) first.

Apart from this comments, I think your patch is quite right.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=520483&group_id=5470