Opened 14 years ago
Closed 14 years ago
#10006 closed defect (fixed)
Wrong wrapping field with long and unicode value in notification email
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.3 |
Component: | notification | Version: | 0.12.2rc1 |
Severity: | normal | Keywords: | unicode email |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
When a property of ticket is long value and contains multibyte characters, the table cells of ticket notification are formatted wrong.
trac.util.text.wrap
uses textwrap.TextWrapper
class. TextWrapper
doesn't support east asian width.
Attachments (3)
Change History (10)
by , 14 years ago
Attachment: | long-prop-values.png added |
---|
follow-up: 2 comment:1 by , 14 years ago
by , 14 years ago
Attachment: | t10006-unicode-textwrap.diff added |
---|
by , 14 years ago
Attachment: | better-wrapping.png added |
---|
comment:2 by , 14 years ago
Status: | new → assigned |
---|
Replying to cboos:
I see that FUJIWARA Katsunori wrote a MBTextWrapper for Mercurial. We can't take the code as is (as it's GPL), but maybe that would be possible with his permission though? Unless you have already started to write something Jun, perhaps you could get in touch with him?
Thanks for the information! But I already started to work this issue, and just completed the patch now. t10006-unicode-textwrap.diff
follow-up: 4 comment:3 by , 14 years ago
Looks very nice! One small question: the textwrap
module import was guarded with a try: except:
in wrap()
. Do you know why this was done? Is the textwrap
module not available on some platforms?
comment:4 by , 14 years ago
Replying to rblank:
Looks very nice! One small question: the
textwrap
module import was guarded with atry: except:
inwrap()
. Do you know why this was done? Is thetextwrap
module not available on some platforms?
I don't know why….
At least the textwrap
module is available since Python 2.3. I removed the try: except:
.
See http://docs.python.org/release/2.3/lib/module-textwrap.html.
comment:5 by , 14 years ago
Right, it's a leftover from the time when Trac supported Python < 2.3. So all ok from my side!
comment:6 by , 14 years ago
I've tested it a bit, seems to work great! Maybe just add a docstring to wrap()
, in particular saying that it supports / expects unicode (it can break for a str
, depending on its content).
comment:7 by , 14 years ago
Milestone: | next-minor-0.12.x → 0.12.3 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Thanks for the reviews! Committed in [10539] with docstring and unit tests.
I see that FUJIWARA Katsunori wrote a MBTextWrapper for Mercurial. We can't take the code as is (as it's GPL), but maybe that would be possible with his permission though? Unless you have already started to write something Jun, perhaps you could get in touch with him?