error with umlauts in directory name

Alexander Belchenko bialix at ukr.net
Fri Feb 9 07:57:16 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel пишет:
> 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

I think for this particular purpose with temp file switch to non-unicode
path is safe on windows. Because you are using the same path to write
file, to run editor with this file and then read file back. In Windows
it's mean instead of unicode path we will use ANSI path that it safe
solution for invoking external editor via subprocess.

- --
Alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFzClczYr338mxwCURAnbJAKCFCve1isrOU8Bo4iQCoCMMO8umlACfRXRY
8uD1XUtFmg0SYkCqBTM2mr4=
=xgMR
-----END PGP SIGNATURE-----




More information about the bazaar mailing list