On Fri, Jun 15, 2012 at 12:19:39PM +0200, Zdeněk Pavlas wrote:
> Convert pw_name to unicode.  This turns cachedirs to unicode
> which may feel bad, but Python seems to handle unicode paths
> correctly (uses utf8 codec instead of ascii).
> 
> open('\xc4\x9b') and open(u'\u011b') opens the same file,
> as expected.
> ---
>  yum/misc.py |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/yum/misc.py b/yum/misc.py
> index 968b5eb..a48a117 100644
> --- a/yum/misc.py
> +++ b/yum/misc.py
> @@ -622,7 +622,7 @@ def getCacheDir(tmpdir='/var/tmp', reuse=True, 
> prefix='yum-'):
>      uid = os.geteuid()
>      try:
>          usertup = pwd.getpwuid(uid)
> -        username = usertup[0]
> +        username = to_unicode(usertup[0])
>      except KeyError:
>          return None # if it returns None then, well, it's bollocksed
>  
What happens with other locales, though?  (For instance, if it's being run
in the C locale?)

If you do this, you may need to explicitly convert back to bytes whenever
you open a file with this in the path.

-Toshio

Attachment: pgpRmCTdkaB38.pgp
Description: PGP signature

_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to