Incorrect support for unicode characters

Bug #151968 reported by Radim Kolář on 2007-10-12
2
Affects Status Importance Assigned to Milestone
bzr-xmloutput
Undecided
Guillermo Gonzalez

Bug Description

bzrxml plugin doesnt seems to handle unicode or better to say nonascii characters well. Redirecting output of bzr to pipe or file on windows-xp seems to change output encoding to ascii. That is a problem because
for example my path to bzr configuration file contains nonascii characters.

i got exception versionxml line 83. ascii codec cant encode (some unicode value here)

more info:

http://bundlebuggy.aaronbentley.com/request/%<email address hidden>%3E

<bialix> you need to add line: encoding_type = 'replace' in the body of cmd_version class in bzrxml plugin
<bialix> and change all print 'foo'
<bialix> to: print >>self.outf, 'foo'
<bialix> that's basically all

Guillermo Gonzalez (verterok) wrote :

applied the recommended changed

Changed in bzr-xmloutput:
status: New → Fix Committed
Radim Kolář (hsn10) wrote :

Problem is still here in revno 30, i think time to dig into bzr version command and check how it displays unicode values. because bzr version have no problems with it

bzr arguments: [u'version', u'--xml']
looking for plugins in C:/Documents and Settings/Radim/Data aplikací­/bazaar/2.0/plugins
looking for plugins in D:\Python\lib\site-packages\bzrlib\plugins
Plugin name __init__ already loaded
Plugin name __init__ already loaded
encoding stdout as bzrlib.user_encoding 'cp1250'
Traceback (most recent call last):
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 800, in run_bzr_catch_errors
    return run_bzr(argv)
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 768, in ignore_pipe
    result = func(*args, **kwargs)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\__init__.py", line 198, in run
    show_version_xml(to_file=self.outf)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\versionxml.py", line 21, in show_version_xml
    _show_bazaar_version(to_file)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\versionxml.py", line 51, in _show_bazaar_version
    _show_bzr_config(to_file)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\versionxml.py", line 83, in _show_bzr_config
    print >>to_file, "<configuration>%s</configuration>" % config_dir
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 59: ordinal not in range(128)

Changed in bzr-xmloutput:
status: Fix Committed → In Progress
Guillermo Gonzalez (verterok) wrote :

I just commited a fix to this problem.
Also, I tested it in Windows XP, here is the output I get:

C:\Documents and Settings\JuanjoE>bzr version --xml
<version>
<bazaar>
<version>0.91.0</version>
<bzrlib>C:\Archivos de programa\Bazaar\lib\library.zip\bzrlib</bzrlib>
<configuration>C:\Documents and Settings\JuanjoE\aplikací\bazaar\2.0</configuration>
<log_file>C:\Documents and Settings\JuanjoE\.bzr.log</log_file>
<copyright>
Copyright 2005, 2006, 2007 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.
</copyright>
</bazaar>
<python>
<dll>C:\Archivos de programa\Bazaar\python25.dll</dll>
<version>2.5.1.final.0</version>
<standard_library>C:\Archivos de programa\Bazaar\lib\library.zip</standard_library>
</python>
</version>

Changed in bzr-xmloutput:
assignee: nobody → guillo.gonzo
status: In Progress → Fix Committed
Changed in bzr-xmloutput:
status: Fix Committed → Fix Released
Radim Kolář (hsn10) wrote :

Its still dont works here. From command line it is ok:

D:\Python\Lib\site-packages\bzrlib\plugins\bzrxml>bzr update
Tree is up to date at revision 32.

D:\Python\Lib\site-packages\bzrlib\plugins\bzrxml>bzr version --xml
<version>
<bazaar>
<version>0.91.0</version>
<bzrlib>D:\Python\lib\site-packages\bzrlib</bzrlib>
<configuration>C:\Documents and Settings\Radim\Data aplikací\bazaar\2.0</configu
ration>
<log_file> C:\Documents and Settings\Radim\.bzr.log </log_file>
<copyright>
Copyright 2005, 2006, 2007 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.
</copyright>
</bazaar>
<python>
<executable>D:\Python\python.exe</executable>
<version>2.4.4.final.0</version>
<standard_library>D:\Python\lib</standard_library>
</python>

</version>

D:\Python\Lib\site-packages\bzrlib\plugins\bzrxml>

bzr called from Eclispe
bzr arguments: [u'version', u'--xml']
looking for plugins in C:/Documents and Settings/Radim/Data aplikacĂ­/bazaar/2.0/plugins
looking for plugins in D:\Python\lib\site-packages\bzrlib\plugins
Plugin name __init__ already loaded
Plugin name __init__ already loaded
encoding stdout as bzrlib.user_encoding 'cp1250'
Traceback (most recent call last):
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 800, in run_bzr_catch_errors
    return run_bzr(argv)
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "D:\Python\Lib\site-packages\bzrlib\commands.py", line 768, in ignore_pipe
    result = func(*args, **kwargs)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\__init__.py", line 229, in run
    show_version_xml(to_file=self.outf)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\versionxml.py", line 42, in show_version_xml
    _show_bazaar_version(to_file)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\versionxml.py", line 72, in _show_bazaar_version
    _show_bzr_config(to_file)
  File "D:\Python\lib\site-packages\bzrlib\plugins\bzrxml\versionxml.py", line 104, in _show_bzr_config
    print >>to_file, u'<configuration>%s</configuration>' % config_dir
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 59: ordinal not in range(128)

I am going to upgrade my Python to 2.5.1 to see if it fixes problem.

Radim Kolář (hsn10) wrote :

updating to python 2.5.1 didnt fixed problem

Guillermo Gonzalez (verterok) wrote :

committed revno 33. I think this time is fixed.

Changed in bzr-xmloutput:
status: Fix Released → In Progress
Guillermo Gonzalez (verterok) wrote :

with the last fix all the tests related to version --xml are green (there is a (work in progress) branch with unittest)

Changed in bzr-xmloutput:
status: In Progress → Fix Committed
Radim Kolář (hsn10) wrote :

I can confirm that version 33 works.
bzr version --xml works in eclipse now.

Guillermo Gonzalez (verterok) wrote :

Great!
Thanks for the help!
Now I'll check the fix with the bzr dev's and if it's all Ok, I'll make new release.

Changed in bzr-xmloutput:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers