Ticket #6979 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[Patch] Error with unicode milestone title

Reported by: fjruiz@citic.es Assigned to: rjollos
Priority: high Component: WikiCalendarMacro
Severity: major Keywords:
Cc: fjruiz@citic.es 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

patch.diff (104 bytes) - added by fjruiz@citic.es on 04/14/10 14:26:53.
Patch that encodes milestone title in utf-8

Change History

04/14/10 14:26:53 changed by fjruiz@citic.es

  • attachment patch.diff added.

Patch that encodes milestone title in utf-8

04/27/10 02:52:07 changed by rjollos

  • status changed from new to closed.
  • resolution set to fixed.

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

(follow-up: ↓ 4 ) 04/27/10 02:52:56 changed 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?

04/27/10 03:00:16 changed by rjollos

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

(in reply to: ↑ 2 ; follow-up: ↓ 8 ) 04/27/10 14:24:21 changed 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.

(follow-up: ↓ 7 ) 05/17/10 22:35:18 changed by neil@dip.sun.ac.za

  • status changed from closed to reopened.
  • resolution deleted.

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.

(follow-up: ↓ 9 ) 05/18/10 05:19:53 changed 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 ...

(in reply to: ↑ 5 ) 05/18/10 12:24:54 changed 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.

(in reply to: ↑ 4 ) 05/18/10 12:26:09 changed 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!

(in reply to: ↑ 6 ) 05/18/10 16:01:58 changed by neil@dip.sun.ac.za

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).

05/18/10 19:51:59 changed by rjollos

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

05/18/10 20:01:53 changed by rjollos

  • status changed from reopened to closed.
  • resolution set to fixed.

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


Add/Change #6979 ([Patch] Error with unicode milestone title)




Change Properties
Action