Modify

Opened 4 years ago

Closed 4 years ago

#6979 closed defect (fixed)

[Patch] Error with unicode milestone title

Reported by: fjruiz@… Owned by: rjollos
Priority: high Component: WikiCalendarMacro
Severity: major Keywords:
Cc: fjruiz@… Trac Release: 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)')

Attachments (1)

patch.diff (104 bytes) - added by fjruiz@… 4 years ago.
Patch that encodes milestone title in utf-8

Download all attachments as: .zip

Change History (12)

Changed 4 years ago by fjruiz@…

Patch that encodes milestone title in utf-8

comment:1 Changed 4 years ago by rjollos

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 follow-up: Changed 4 years ago by rjollos

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 4 years ago by rjollos

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: Changed 4 years ago by anonymous

Replying to rjollos:

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: Changed 4 years ago by neil@…

  • Resolution fixed deleted
  • Status changed from closed to 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: Changed 4 years ago by rjollos

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 4 years ago by anonymous

Replying to neil@dip.sun.ac.za:

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 4 years ago by anonymous

Replying to anonymous:

Replying to rjollos:

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 4 years ago by neil@…

Replying to rjollos:

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 4 years ago by rjollos

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

comment:11 Changed 4 years ago by rjollos

  • Resolution set to fixed
  • Status changed from reopened to closed

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

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.