[PATCH] alias: fixes exception when displaying translated help text

Yuya Nishihara yuya at tcha.org
Thu Feb 25 09:54:29 CST 2010

Yuya Nishihara wrote:
> alias: fixes exception when displaying translated help text
> docstring of aliased command can contain non-ASCII characters
> since 6e8a16dd3e30, so we cannot do gettext() against it.

Traceback follows:
% hg show
hg show: option -r requires argument
hg show [OPTION]... [FILE]          
Traceback (most recent call last):  
  File "/home/yuya/bin/hg", line 27, in <module>
  File "/home/yuya/work/hghacks/mercurial-stable/mercurial/dispatch.py", line 16, in run
  File "/home/yuya/work/hghacks/mercurial-stable/mercurial/dispatch.py", line 30, in dispatch
    return _runcatch(u, args)                                                                
  File "/home/yuya/work/hghacks/mercurial-stable/mercurial/dispatch.py", line 76, in _runcatch
    commands.help_(ui, inst.args[0])                                                          
  File "/home/yuya/work/hghacks/mercurial-stable/mercurial/commands.py", line 1671, in help_  
  File "/home/yuya/work/hghacks/mercurial-stable/mercurial/commands.py", line 1546, in helpcmd
    doc = gettext(doc)                                                                        
  File "/home/yuya/work/hghacks/mercurial-stable/mercurial/i18n.py", line 39, in gettext      
    u = t.ugettext(message)                                                                   
  File "/usr/lib/python2.5/gettext.py", line 404, in ugettext                                 
    return unicode(message)                                                                   
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 12: ordinal not in range(128)

> -        doc = gettext(entry[0].__doc__)
> +        doc = entry[0].__doc__
> +        if not hasattr(entry[0], 'badalias'):  # cmdalias: already translated
> +            doc = gettext(doc)
>          if not doc:
>              doc = _("(no help text available)")
>          if ui.quiet:

I feel this is ugly.
Any comments are appreciated.


More information about the Mercurial-devel mailing list