<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 03/06/2014 06:41 AM, Sheldon wrote:<br>
    </div>
    <blockquote cite="mid:531842B9.5020708@linux.vnet.ibm.com"
      type="cite">On 03/05/2014 03:35 AM, Aline Manera wrote:
      <br>
      <blockquote type="cite">From: Aline Manera
        <a class="moz-txt-link-rfc2396E" href="mailto:alinefm@br.ibm.com">&lt;alinefm@br.ibm.com&gt;</a>
        <br>
        <br>
        The error message and all its parameters must be string.
        <br>
        So convert error code to string in order to accomplish it.
        <br>
        <br>
        Signed-off-by: Aline Manera <a class="moz-txt-link-rfc2396E" href="mailto:alinefm@br.ibm.com">&lt;alinefm@br.ibm.com&gt;</a>
        <br>
        ---
        <br>
          src/kimchi/auth.py |    2 +-
        <br>
          1 file changed, 1 insertion(+), 1 deletion(-)
        <br>
        <br>
        diff --git a/src/kimchi/auth.py b/src/kimchi/auth.py
        <br>
        index af3b610..b16f2db 100644
        <br>
        --- a/src/kimchi/auth.py
        <br>
        +++ b/src/kimchi/auth.py
        <br>
        @@ -107,7 +107,7 @@ def authenticate(username, password,
        service="passwd"):
        <br>
              try:
        <br>
                  auth.authenticate()
        <br>
              except PAM.error, (resp, code):
        <br>
        -        msg_args = {'userid': username, 'code': code}
        <br>
        +        msg_args = {'userid': username, 'code': str(code)}
        <br>
                  raise OperationFailed("KCHAUTH0001E", msg_args)
        <br>
        <br>
              return True
        <br>
      </blockquote>
      How about the follow change?
      <br>
      It can avoid call str() before we raise KimchiException
      Everywhere.
      <br>
      Also I think it is not good to other developers to call str
      explicitly Everywhere.
      <br>
      <br>
      diff --git a/src/kimchi/exception.py b/src/kimchi/exception.py
      <br>
      index 71a4d11..73e88ce 100644
      <br>
      --- a/src/kimchi/exception.py
      <br>
      +++ b/src/kimchi/exception.py
      <br>
      @@ -50,7 +50,7 @@ class KimchiException(Exception):
      <br>
      translation = gettext
      <br>
      <br>
      for key, value in args.iteritems():
      <br>
      - if not isinstance(value, unicode):
      <br>
      + if isinstance(value, str):
      <br>
      args[key] = unicode(value, 'utf-8')
      <br>
      <br>
      return unicode(translation.gettext(text), 'utf-8') % args
      <br>
      <br>
      <br>
      <br>
    </blockquote>
    <br>
    What about always convert to string before to unicode?<br>
    <br>
    if not isinstance(value, unicode):<br>
       args[key] = unicode(<b>str</b>(value), 'utf-8')<br>
    <br>
    That way we guarantee everything will be unicode in the end.<br>
    <br>
  </body>
</html>