UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 584: ordinal not in range(128) at line 221 : "return result + rest"

Bug #893679 reported by NeTgUeSh
This bug report is a duplicate of:  Bug #448129: unicode handling problem. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar Keywords Plugin
New
Undecided
Unassigned

Bug Description

Using the bzr-keywords plugin, I (systematicaly) got the following call stack :

bzr: ERROR: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 584: ordinal not in range(128)

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 946, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 1150, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 699, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 721, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/cleanup.py", line 135, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/home/LOGIWAYS/<user>/.config/bazaar/plugins/keywords/__init__.py", line 223, in run
    return super(cmd_export, self).run(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/builtins.py", line 2990, in run
    per_file_timestamps=per_file_timestamps)
  File "/usr/lib/pymodules/python2.6/bzrlib/export/__init__.py", line 163, in export
    per_file_timestamps, fileobj):
  File "/usr/lib/pymodules/python2.6/bzrlib/export/__init__.py", line 130, in get_export_generator
    force_mtime=force_mtime, fileobj=fileobj):
  File "/usr/lib/pymodules/python2.6/bzrlib/export/dir_exporter.py", line 85, in dir_exporter_generator
    chunks = filtered_output_bytes(chunks, filters, context)
  File "/usr/lib/pymodules/python2.6/bzrlib/filters/__init__.py", line 169, in filtered_output_bytes
    chunks = filter.writer(chunks, context)
  File "/home/LOGIWAYS/<user>/.config/bazaar/plugins/keywords/keywords.py", line 259, in _normal_kw_expander
    return _kw_expander(chunks, context)
  File "/home/LOGIWAYS/<user>/.config/bazaar/plugins/keywords/keywords.py", line 254, in _kw_expander
    encoder=encoder)]
  File "/home/LOGIWAYS/<user>/.config/bazaar/plugins/keywords/keywords.py", line 221, in expand_keywords
    return result + rest
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 584: ordinal not in range(128)

bzr 2.4.2 on python 2.6.6 (Linux-2.6.35-30-generic-x86_64-with-
    Ubuntu-10.10-maverick)
arguments: ['/usr/bin/bzr', 'export', '/home/LOGIWAYS/<user>/Documents/MG
    L_WORKSHOP/DRM/Sources/plugin_lwdrm/docs/output/export', '--
    keywords=publish']
plugins: avahi[0.3.0dev], bash_completion[2.4.2], builder[unknown],
    bzr_buildbot[unknown], bzrtools[2.4.1], changelog_merge[2.4.2],
    dbus[0.1.0dev], diff_revid[unknown], email[unknown], explorer[1.2.1],
    extmerge[unknown], fastimport[0.11.0], gtk[0.100.0], keywords[unknown],
    launchpad[2.4.2], loom[2.2.1dev],
    netrc_credential_store[2.4.2], news_merge[2.4.2], pqm[1.4.0dev],
    qbzr[0.21.1], rewrite[0.6.2], shell_completer[unknown], sloecode[unknown],
    stats[0.1.0], upload[1.0.1dev], vimdiff[unknown], weave_fmt[2.4.2],
    xmloutput[0.8.8]
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'fr_FR.UTF-8'

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.
make: *** [export] Erreur 4

I have a quick fix for this issue... I noticed that the type of 'result' variable is 'unicode' ($PYTHON > type(result)) and the type of 'rest' is 'str' ($PYTHON > type(str)). Python was not able to transtype the 'result + rest' operation.

So the fix consist to replace : 'result + rest' by 'str(result) + str(rest)'

Revision history for this message
Martin Packman (gz) wrote :

Thanks for the report, converting the unicode part to a byte string sounds like the right idea, but unfortunately just using str() is probably not enough, some kind of encoding probably needs to happen. Follow up in the existing bug if you have more thoughts.

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.