<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">于 2014/3/6 22:53, Aline Manera 写道:<br>
</div>
<blockquote cite="mid:53188BF6.5090308@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<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
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:alinefm@br.ibm.com"><alinefm@br.ibm.com></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 moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:alinefm@br.ibm.com"><alinefm@br.ibm.com></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>
</blockquote>
<br>
I think it is more pythonic that:<br>
<br>
try:<br>
args[key] = unicode(value, 'utf-8')<br>
except TypeError:<br>
args[key] = unicode(<b>str</b>(value), 'utf-8')
<blockquote cite="mid:53188BF6.5090308@linux.vnet.ibm.com"
type="cite"> <br>
That way we guarantee everything will be unicode in the end.<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>