[Python-bugs-list] [ python-Bugs-622831 ] textwrap fails on unicode using defaults
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 09 Dec 2002 08:24:01 -0800
Bugs item #622831, was opened at 2002-10-14 00:07
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=622831&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Pending
>Resolution: Fixed
Priority: 5
Submitted By: R. David Murray (rdmurray)
Assigned to: Greg Ward (gward)
Summary: textwrap fails on unicode using defaults
Initial Comment:
I don't know if this is a module bug or a documentation bug. I'm
using the documentation from the manual on python.org.
>>> x = TextWrapper()
>>> x.wrap(u'abcd')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/textwrap.py", line 239, in wrap
text = self._munge_whitespace(text)
File "/usr/local/lib/python2.3/textwrap.py", line 99, in _munge_whitespace
text = text.translate(self.whitespace_trans)
TypeError: character mapping must return integer, None or unicode
If you do x.replace_whitespace = True, then it will wrap the text.
So either whitespace replacement needs to be fixed, or the docs
need to be updated to note that you have to set replace_whitespace
to false if you want to wrap unicode.
----------------------------------------------------------------------
>Comment By: Greg Ward (gward)
Date: 2002-12-09 11:24
Message:
Logged In: YES
user_id=14422
Hopefully fixed in rev 1.19 of textwrap.py. Not in test
suite yet, so I'm leaving this one "pending".
----------------------------------------------------------------------
Comment By: Greg Ward (gward)
Date: 2002-10-22 14:30
Message:
Logged In: YES
user_id=14422
I'm almost competely ignorant of Unicode, and so is textwrap.py.
I'll try to get help on python-dev to fix this, or figure it out myself.
Failing that, the inability to handle Unicode should be documented.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-10-14 08:48
Message:
Logged In: YES
user_id=21627
Greg, can you take a look?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=622831&group_id=5470