On Thu, Sep 15, 2011 at 07:55:54PM +0530, Paresh Mutha wrote:
> Hello,
> 
> We had a bugzilla #701344 opened on RHN Satellite where package
> profile sync would fail if the package name has non-ascii chars in
> it. I have created a patch on this issue.
> 
> As it applies to spacewalk as well, I have attached the patch for it.
> 
> Regards,
> Paresh

> >From 48288da277e514411ee6ada4ac8d8ca4cf5979a2 Mon Sep 17 00:00:00 2001
> From: Paresh Mutha <pmu...@redhat.com>
> Date: Thu, 15 Sep 2011 19:23:31 +0530
> Subject: [PATCH 3/3] Fix to handle non-ascii chars in package name
>  Signed-off-by: Paresh Mutha <pmu...@redhat.com>
> 
> ---
>  backend/server/rhnServer/server_packages.py |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/backend/server/rhnServer/server_packages.py 
> b/backend/server/rhnServer/server_packages.py
> index 29e6b87..6129597 100644
> --- a/backend/server/rhnServer/server_packages.py
> +++ b/backend/server/rhnServer/server_packages.py
> @@ -24,6 +24,7 @@ from types import DictType
>  from spacewalk.common import log_debug, rhnFault, rhn_rpm
>  from spacewalk.server import rhnSQL
>  from server_lib import snapshot_server, check_entitlement
> +from types import UnicodeType
>  
>  UNCHANGED = 0
>  ADDED     = 1
> @@ -46,6 +47,8 @@ class dbPackage:
>          for k in ('name', 'version', 'release', 'epoch', 'arch'):
>              if pdict[k] == None:
>                  return None
> +        if type(pdict['name']) == UnicodeType:
> +            pdict['name'] = unicode.encode(pdict['name'],'utf-8')

I don't like the fact that you are taking a perfectly valid Unicode
string and convert it to a stream of bytes. You should only do that
when you are ready to output the value to an environment which cannot
handle the Unicode strings or which is binary/byte-oriented.

Looking at the bug 701344, you should really investigate what
operation it is that fails, not do a wholesale change of the type.

Nack for now.

-- 
Jan Pazdziora
Principal Software Engineer, Satellite Engineering, Red Hat

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to