On Sat, May 14, 2011 at 10:04 PM, Martin [gz] <email address hidden> wrote:
> Okay, nearly there. Two tests from textwrapper that use `fix_sentence_endings=True` fail because of this code in the textwrap module which puts bytestrings in the chunks list:
>
> if chunks[i+1] == " " and pat.search(chunks[i]):
> chunks[i+1] = " "
>
> Resulting in errors like:
>
> Traceback (most recent call last):
> ...
> File "...\lib\test\test_textwrap.py", line 102, in test_fix_sentence_endings
> self.check(wrapper.wrap(text), expect)
> File "...\i18n-utextwrap\bzrlib\utextwrap.py", line 216, in wrap
> return textwrap.TextWrapper.wrap(self, unicode(text))
> File "...\lib\textwrap.py", line 321, in wrap
> return self._wrap_chunks(chunks)
> File "...\i18n-utextwrap\bzrlib\utextwrap.py", line 172, in _wrap_chunks
> l = self._width(chunks[-1])
> File "...\i18n-utextwrap\bzrlib\utextwrap.py", line 95, in _width
> return sum(charwidth(c) for c in s)
> File "...\i18n-utextwrap\bzrlib\utextwrap.py", line 95, in <genexpr>
> return sum(charwidth(c) for c in s)
> File "...\i18n-utextwrap\bzrlib\utextwrap.py", line 86, in _unicode_char_width
> return (_eawidth(uc) in self._east_asian_doublewidth and 2) or 1
> TypeError: must be unicode, not str
>
> Annoying. That option is pretty bogus anyway, I'd not mind just not supporting it. Otherwise _fix_sentence_endings needs overriding so it doesn't mix up types in the chunks list.
I've overrided the _fix_sentence_endings.
Why I miss the error is I used another Python environment when
removing cast to unicode.
To avoid this, I've added empty test case that raises TestSkipped when
test.test_textwrap
is unavailable.
On Sat, May 14, 2011 at 10:04 PM, Martin [gz] <email address hidden> wrote: endings= True` fail because of this code in the textwrap module which puts bytestrings in the chunks list: chunks[ i]): test\test_ textwrap. py", line 102, in test_fix_ sentence_ endings wrapper. wrap(text) , expect) utextwrap\ bzrlib\ utextwrap. py", line 216, in wrap TextWrapper. wrap(self, unicode(text)) textwrap. py", line 321, in wrap chunks( chunks) utextwrap\ bzrlib\ utextwrap. py", line 172, in _wrap_chunks chunks[ -1]) utextwrap\ bzrlib\ utextwrap. py", line 95, in _width utextwrap\ bzrlib\ utextwrap. py", line 95, in <genexpr> utextwrap\ bzrlib\ utextwrap. py", line 86, in _unicode_char_width asian_doublewid th and 2) or 1 endings needs overriding so it doesn't mix up types in the chunks list.
> Okay, nearly there. Two tests from textwrapper that use `fix_sentence_
>
> if chunks[i+1] == " " and pat.search(
> chunks[i+1] = " "
>
> Resulting in errors like:
>
> Traceback (most recent call last):
> ...
> File "...\lib\
> self.check(
> File "...\i18n-
> return textwrap.
> File "...\lib\
> return self._wrap_
> File "...\i18n-
> l = self._width(
> File "...\i18n-
> return sum(charwidth(c) for c in s)
> File "...\i18n-
> return sum(charwidth(c) for c in s)
> File "...\i18n-
> return (_eawidth(uc) in self._east_
> TypeError: must be unicode, not str
>
> Annoying. That option is pretty bogus anyway, I'd not mind just not supporting it. Otherwise _fix_sentence_
I've overrided the _fix_sentence_ endings.
Why I miss the error is I used another Python environment when
removing cast to unicode.
To avoid this, I've added empty test case that raises TestSkipped when
test.test_textwrap
is unavailable.
> -- /code.launchpad .net/~songofaca ndy/bzr/ i18n-utextwrap/ +merge/ 59950
> https:/
> You are the owner of lp:~songofacandy/bzr/i18n-utextwrap.
>
--
INADA Naoki <email address hidden>