[Python-bugs-list] [ python-Bugs-622831 ] textwrap fails on unicode using defaults

noreply@sourceforge.net noreply@sourceforge.net
Sun, 13 Oct 2002 21:07:44 -0700


Bugs item #622831, was opened at 2002-10-13 20: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: Open
Resolution: None
Priority: 5
Submitted By: R. David Murray (rdmurray)
Assigned to: Nobody/Anonymous (nobody)
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.


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=622831&group_id=5470