Opened 12 years ago

Closed 12 years ago

# [Patch] Error with unicode milestone title

Reported by: Owned by: FranRuiz Ryan J Ollos high WikiCalendarMacro major FranRuiz 0.11

### Description

If day milestone name contains any non-ascii character, the macro fails on writing it to the buffer with:

Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 480, in _macro_formatter
return macro.process(args, in_paragraph=True)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 180, in process
text = self.processor(text)
File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 167, in _macro_processor
text)
File "/var/trac/test-erp/plugins/WikiCalendarMacro.py", line 283, in expand_macro
'day': day
UnicodeEncodeError: ('ascii', u'\n<td><a class="day milestone" href="/test/wiki/Meeting/2010/01/21?action=edit" title="Milestone: Primera iteraci\xf3n - Create page Meeting/2010/01/21">21</a></td>', 120, 121, 'ordinal not in range(128)')


### Changed 12 years ago by FranRuiz

Patch that encodes milestone title in utf-8

### comment:1 Changed 12 years ago by Ryan J Ollos

Resolution: → fixed new → closed

(In [7891]) Handle milestone names with non-ascii characters. Thank you fjruiz. Fixes #6979.

### comment:2 follow-up:  4 Changed 12 years ago by Ryan J Ollos

I went ahead and applied the patch. I haven't had time to test after applying the patch. Would you be willing to test the latest version of the trunk?

### comment:3 Changed 12 years ago by Ryan J Ollos

Also, please go ahead and list your name in the list of Contributors on the wiki page, if you like.

### comment:4 in reply to:  2 ; follow-up:  8 Changed 12 years ago by anonymous

I went ahead and applied the patch. I haven't had time to test after applying the patch. Would you be willing to test the latest version of the trunk?

It worked for me but I'll test the trunk version as soon as I can.

### comment:5 follow-up:  7 Changed 12 years ago by neil@…

Resolution: fixed closed → reopened

r7891 looks wrong to me - surely it should be title.encode('utf-8') ?

With the current version, I'm seeing "'str' object has no attribute 'unicode'" errors.

### comment:6 follow-up:  9 Changed 12 years ago by Ryan J Ollos

Assuming that the patch author generated the patch from a working version and it was working for him, I'd have to guess that this is dependent on the version of Python you're using. Just a guess though ...

### comment:7 in reply to:  5 Changed 12 years ago by anonymous

r7891 looks wrong to me - surely it should be title.encode('utf-8') ?

I think that according to trac:TracUnicode it's a good idea to use UTF-8 encoding.

With the current version, I'm seeing "'str' object has no attribute 'unicode'" errors.

It would be useful to know which version of Python and system locale are you using.

### comment:8 in reply to:  4 Changed 12 years ago by anonymous

I went ahead and applied the patch. I haven't had time to test after applying the patch. Would you be willing to test the latest version of the trunk?

It worked for me but I'll test the trunk version as soon as I can.

Yes, the trunk version works for me!

### comment:9 in reply to:  6 Changed 12 years ago by neil@…

Assuming that the patch author generated the patch from a working version and it was working for him, I'd have to guess that this is dependent on the version of Python you're using.

The patch attached to this ticket uses title.encode, so I'm not sure were the unicode method used in r7891 came from.

I'm not aware of any version of python which has a unicode method on string objects.

For reference, this fails with both python 2.5 and 2.6 here (trac 0.11.5 in both cases).

### comment:10 Changed 12 years ago by Ryan J Ollos

Stupid mistake on my part ... caused by drinking and patching. I'll fix it in a moment. Thanks for catching this.

### comment:11 Changed 12 years ago by Ryan J Ollos

Resolution: → fixed reopened → closed

(In [7965]) Fix defect that I (stupidly) introduced in [7891]. Fixes #6979.

### Modify Ticket

Change Properties