"format_signature_validity" (in log.py) throws UnicodeEncodeError when signature contains non-ascii character

Bug #1037108 reported by Thomas Krause on 2012-08-15
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar
Low
Unassigned

Bug Description

When accessing a repository which has signed commits and where the name of the author contains non ASCII characters you will get an UnicodeEncodeError when trying to get the log if signature display is enabled.

E.g. you can try

bzr log --signatures lp:~pixeldrama/annis/restr_vis -r 973..975

or

bzr qlog lp:~pixeldrama/annis/restr_vis
(click on the revision 975 to get the error)

The problem is in bzrlib/log.py in the function "format_signature_validity" which mixes a constant non-unicode string with a unicode string which is given as argument for the format function.

if you change

-------------------------
if result[0] == gpg.SIGNATURE_VALID:
        return "valid signature from {0}".format(result[1])
    if result[0] == gpg.SIGNATURE_KEY_MISSING:
        return "unknown key {0}".format(result[1])
-------------------------

to

-------------------------
if result[0] == gpg.SIGNATURE_VALID:
        return u"valid signature from {0}".format(result[1])
    if result[0] == gpg.SIGNATURE_KEY_MISSING:
        return u"unknown key {0}".format(result[1])
-------------------------

everything works fine. This was tested with bazaar 2.5.1 in Ubuntu but the error also exists in lp:bzr

bzr version
=========
Bazaar (bzr) 2.5.1
  Python interpreter: /usr/bin/python 2.7.3
  Python standard library: /usr/lib/python2.7
  Platform: Linux-3.2.0-29-generic-x86_64-with-Ubuntu-12.04-precise
  bzrlib: /usr/lib/python2.7/dist-packages/bzrlib

Backtrace from bzr.log
===================

Mi 2012-08-15 14:35:26 +0200
0.055 bazaar version: 2.5.1
0.055 bzr arguments: [u'qlog']
0.057 looking for plugins in /home/thomas/.bazaar/plugins
0.063 looking for plugins in /usr/lib/python2.7/dist-packages/bzrlib/plugins
0.098 encoding stdout as sys.stdout encoding 'UTF-8'
0.315 opening working tree '/home/thomas/annis/restr_vis'
7.913 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/qbzr/lib/util.py", line 908, in run_in_loading_queue
    f(*args, **kargs)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/qbzr/lib/uifactory.py", line 32, in decorate
    r = f(*args, **kargs)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/qbzr/lib/revisionmessagebrowser.py", line 365, in update_selection
    revids, self.log_list.log_model.graph_viz.get_repo_revids)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/qbzr/lib/revisionmessagebrowser.py", line 149, in set_display_revids
    pass_prev_loaded_rev=True)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/qbzr/lib/lazycachedrevloader.py", line 53, in load_revisions
    revisions_loaded(return_revisions, False)
  File "/usr/lib/python2.7/dist-packages/bzrlib/plugins/qbzr/lib/revisionmessagebrowser.py", line 204, in revisions_loaded
    cached_revisions[revid].repository)
  File "/usr/lib/python2.7/dist-packages/bzrlib/log.py", line 346, in format_signature_validity
    return "valid signature from {0}".format(result[1])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 12: ordinal not in range(128)

Related branches

Thomas Krause (krause) on 2012-08-15
description: updated
Thomas Krause (krause) wrote :
Martin Packman (gz) wrote :

That change looks like a good start, would you like propose it for merging? See this wiki page and the ones following on:

<https://help.launchpad.net/Code>

John A Meinel (jameinel) on 2012-08-21
Changed in bzr:
importance: Undecided → Low
status: New → In Progress
Reagan Sanders (vexo) wrote :

Marked as a duplicate of bug #1123460 even though this one is older, as this issue is a subset of the (somewhat) related pair issues there.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers