UnicodeDecodeError on 'log -p'

Bug #328007 reported by Alexandre Garnier
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Undecided
Alexander Belchenko

Bug Description

'log -p' have problems with files encoding.
'diff' works fine to show the patch.

$ bzr log -p -r-2
------------------------------------------------------------
revno: 1111
committer: XXX
branch nick: XXX
timestamp: Tue 2009-02-10 12:37:09 +0100
message:
  XXX
diff:
=== modified file 'file'
--- file 2009-02-04 17:44:37 +0000
+++ file 2009-02-10 11:37:09 +0000
@@ -470,4 +470,123 @@
 RewriteRule AAA BBB [R=301,L,NE]

 RewriteRule "CCC" "DDD" [NE,QSA,L,R=301]
+
+
+
bzr: ERROR: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 50: ordinal not in range(128)

Traceback (most recent call last):
  File "/opt/lib/python/bzrlib/commands.py", line 893, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/opt/lib/python/bzrlib/commands.py", line 839, in run_bzr
    ret = run(*run_argv)
  File "/opt/lib/python/bzrlib/commands.py", line 539, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/opt/lib/python/bzrlib/commands.py", line 853, in ignore_pipe
    result = func(*args, **kwargs)
  File "/opt/lib/python/bzrlib/builtins.py", line 1950, in run
    show_diff=show_diff)
  File "/opt/lib/python/bzrlib/log.py", line 182, in show_log
    start_revision, end_revision, search, limit, show_diff)
  File "/opt/lib/python/bzrlib/log.py", line 239, in _show_log
    lf.log_revision(lr)
  File "/opt/lib/python/bzrlib/log.py", line 1248, in log_revision
    self.show_diff(to_file, revision.diff, indent)
  File "/opt/lib/python/bzrlib/log.py", line 1193, in show_diff
    to_file.write(indent + '%s\n' % (l,))
  File "/opt/lib/python/codecs.py", line 303, in write
    data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 50: ordinal not in range(128)

bzr 1.12rc1 on python 2.5.2 (linux2)
arguments: ['/opt/bin/bzr', '--no-plugins', 'log', '-p']
encoding: 'ISO-8859-1', fsenc: 'ISO-8859-1', lang: 'en_US'
plugins:
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Tags: log
Revision history for this message
Colin Watson (cjwatson) wrote :

I'm seeing this too. A reproduction case is to check out lp:~ubuntu-installer/ubiquity/trunk and run 'bzr log -p -r3043'.

Changed in bzr:
status: New → Confirmed
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Hmm. diff has an excoding of 'exact' and log has an encoding of 'replace'. Changing log's encoding to be 'exact' fixes this bug but breaks lots of other tests. I'll need to think about this some more and get some opinions from others as to the best way to proceed here.

Revision history for this message
John A Meinel (jameinel) wrote :

'log -p' would need 'exact' because you are spitting out diff hunks. The problem is that you are *also* writing out Unicode log messages and usernames. So it means changing log to 'exact' and then manually updating all of the log formatting code to handle a custom output encoding...

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Alexander Belchenko has been kind enough to put together a patch for this that I'll attach. It still needs some tests before it can be merged. I hope to do those soon.

Revision history for this message
Alexander Belchenko (bialix) wrote :

merged in bzr.dev trunk as revno 4128

Changed in bzr:
assignee: nobody → bialix
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.