<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/05/2014 11:59 AM, Sheldon wrote:<br>
</div>
<blockquote cite="mid:5316A12D.2000705@linux.vnet.ibm.com"
type="cite">On 03/05/2014 09:49 AM, Shu Ming wrote:
<br>
<blockquote type="cite">2014/3/5 3:35, Aline Manera:
<br>
<blockquote type="cite">From: Aline Manera
<a 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>
</blockquote>
<br>
I think the code is str already. Why should it be converted
explicitly? Is there any error encountered?
<br>
</blockquote>
agree.
<br>
Also python can converted the parameters well when format the
string.
<br>
This is different with C code.
<br>
<br>
such as:
<br>
In [218]: "This is a code test: %(code)s " % {"code": 2}
<br>
Out[218]: 'This is a code test: 2 '
<br>
<br>
<br>
so is this is need?
<br>
IMO, if we still need it to be converted explicitly. We can use
%d, instead of %s as follow.
<br>
<br>
In [221]: "This is a code test: %(code)d " % {"code": 2}
<br>
Out[221]: 'This is a code test: 2 '
<br>
</blockquote>
<br>
for int, it is no need to be converted explicitly<br>
In [250]: int.__str__<br>
Type: wrapper_descriptor<br>
String Form:<slot wrapper '__str__' of 'int' objects><br>
Namespace: Python builtin<br>
Docstring: x.__str__() <==> str(x)<br>
<br>
<br>
<br>
How I will give a example about how %s works. <br>
<br>
In [234]: class a(object):<br>
.....: def __str__(self):<br>
.....: return "b"<br>
.....: <br>
<br>
In [235]: class ca(object):<br>
def __str__(self):<br>
return "b"<br>
.....: <br>
<br>
In [236]: class ca(object):<br>
.....: def __str__(self):<br>
.....: return "b"<br>
.....: <br>
<br>
In [237]: ia = ca()<br>
<br>
In [238]: <font color="#3333ff">print ia<br>
b</font><br>
<br>
In [239]: <font color="#3333ff">"%s" % ia<br>
Out[239]: 'b'<br>
</font><br>
<br>
In [240]: class ca(object): pass<br>
<br>
In [241]: ia = ca()<br>
<br>
In [242]: <font color="#3333ff">print ia<br>
<__main__.ca object at 0x2b705d0></font><br>
<br>
In [243]: <font color="#3333ff">"%s" % ia<br>
Out[243]: '<__main__.ca object at 0x2b705d0>'</font><br>
<br>
<br>
<blockquote cite="mid:5316A12D.2000705@linux.vnet.ibm.com"
type="cite">
<blockquote type="cite">
<br>
<blockquote type="cite">
<br>
Signed-off-by: Aline Manera <a 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>
<br>
_______________________________________________
<br>
Kimchi-devel mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Thanks and best regards!
Sheldon Feng(冯少合)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
IBM Linux Technology Center</pre>
</body>
</html>