[Yum-devel] [PATCH] non-ascii pw_name => cachedir => lockfile. BZ 832195

Toshio Kuratomi a.badger at gmail.com
Fri Jun 15 15:30:48 UTC 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20120615/b2dd2810/attachment.asc>


More information about the Yum-devel mailing list