error with umlauts in directory name

John Arbash Meinel john at arbash-meinel.com
Wed Feb 7 16:58:22 GMT 2007


Martin Steigerwald wrote:
> Please also CC to my personal address as I am not subcribed to list.
> 
> 
> Hello!
> 
> Now that it happens again I do so as advised and send this error message.
> 
> It happens on commit after I changed a file and added some more.
> 

hmm...

Well, as a workaround you can use 'bzr commit -m "message"' to avoid
this bug, but certainly we need to fix this.

>   File "/usr/lib/python2.4/site-packages/bzrlib/msgeditor.py", line 98, in 
> edit_commit_message
>     tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.', 
> dir=u'.')
...

v- It seems like os.path.abspath() is having a problem with getcwd()
since it is thinking in terms of 8-bit string path, while we are
thinking in terms of unicode path.

>   File "tempfile.py", line 238, in _mkstemp_inner
>     return (fd, _os.path.abspath(file))
>   File "posixpath.py", line 403, in abspath
>     path = join(os.getcwd(), path)
>   File "posixpath.py", line 65, in join
>     path += '/' + b
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 30: 
> ordinal not in range(128)

> All the files I want to update / add are same locale.
> 
> I have no time for further investigation right now or to write a bug 
> report... so this will have to do it for now.
> 
> I worked around the bug by issuing:
> 
> bzr mv Wünsche Wuensche
> 
> (i.e. removing the umlaut from the directory name)
> 
> Regards,

The other way of avoiding this bug is to cd to the root of your project
and run commit from there, rather than running commit in a subdirectory.

The specific bug is in python's 'tempfile.mkstemp' function. Which
doesn't seem to handle non-ascii paths very well.

I wonder what python is making of your locale, could you put the
attached file into ~/.bazaar/plugins/

And then run a bzr command ('bzr rocks' is fine)

It should print out what encoding bzr thinks you are running in.

Otherwise, my suggested patch is the simple one, which may mean things
don't work properly in certain paths on Windows

=== modified file 'bzrlib/msgeditor.py'
--- bzrlib/msgeditor.py 2006-11-11 19:25:25 +0000
+++ bzrlib/msgeditor.py 2007-02-07 16:53:59 +0000
@@ -95,7 +95,7 @@

     msgfilename = None
     try:
-        tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.',
dir=u'.')
+        tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.',
dir='.')
         msgfile = os.close(tmp_fileno)
         if infotext is not None and infotext != "":
             hasinfo = True

Or the attached one which is more involved, but cleans up a bunch of
other stuff. The big difference is just that it uses:
dir=osutils.getcwd()

Which returns the full unicode path to the current directory, which
should just be a pass-through for os.abspath(), rather than having
abspath try to join an 8-bit string with u'.'

Are you able to try these fixes?

John
=:->



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: check_locale.py
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070207/b094eace/attachment.diff 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cleanup_msgeditor.diff
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070207/b094eace/attachment-0001.diff 


More information about the bazaar mailing list