#80 printing unicode subclass instance => TypeError

closed-fixed
nobody
pythonwin (176)
5
2004-04-22
2004-01-30
Jason Orendorff
No

Ramon M. Felciano reported this problem to me.

The bug happens when you enter code like the following
into PythonWin's interactive window:

class x(unicode):
pass

print x(u'hello world')

(Full traceback at the bottom of this message.)

I have win32all build 163. In this version, line 440
of
"{PYTHONHOME}\lib\site-packages\Pythonwin\pywin\framework\winout.py"
reads:

if type(item) != UnicodeType:

Changing this to "if not isinstance(type,
UnicodeType):" fixes the problem for me, and I think it
works in Python 2.2 as well; before that I dunno.

(The reason this comes up at all is that my path class,
http://www.jorendorff.com/articles/python/path, is a
subclass of unicode on Windows.)

PythonWin 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC
v.1200 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond
(mhammond@skippinet.com.au) - see 'Help/About
PythonWin' for further copyright information.
>>> class x(unicode):
... pass
...
>>> print x(u'hello world')

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File
"C:\PROGRA~1\PYTHON~1.3\lib\site-packages\Pythonwin\pywin\framework\winout.py",
line 172, in write
return self.template.write(msg)
File
"C:\PROGRA~1\PYTHON~1.3\lib\site-packages\Pythonwin\pywin\framework\winout.py",
line 487, in write
self.HandleOutput(message)
File
"C:\PROGRA~1\PYTHON~1.3\lib\site-packages\Pythonwin\pywin\framework\winout.py",
line 468, in HandleOutput
self.QueueFlush()
File
"C:\PROGRA~1\PYTHON~1.3\lib\site-packages\Pythonwin\pywin\framework\winout.py",
line 441, in QueueFlush
item = unicode(item, default_platform_encoding)
TypeError: decoding Unicode is not supported

Discussion

  • Mark Hammond
    Mark Hammond
    2004-04-22

    • status: open --> closed-fixed
     
  • Mark Hammond
    Mark Hammond
    2004-04-22

    Logged In: YES
    user_id=14198

    This is fixed in build 200, but by accident -
    is_platform_unicode is never true any more. However, your
    fix is still correct, and will be checked in.