On 03/06/2014 11:46 PM, Crístian Viana wrote:
Am 06-03-2014 12:12, schrieb Sheldon:
> AFAK, seems two types has no string representation, one is unicode
> and another is object derived from nothing.
The statement if not isinstance(value, unicode), which is in the
sample code above, makes sure that we will not try to convert a
unicode object to string (only those who have a different type).
I have forgot to
tell one result I have tried:
In [24]: u"fo(o( = %s" % "fo(o("
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
only this case need the statement if not isinstance(value, unicode),
In [23]: u"fo(o( = %s" % u"fo(o("
Out[23]: u'f\u01d2\u01d2 = f\u01d2\u01d2'
not find other case.
if you find, you can tell us.
Thanks.
And an object derived from nothing also has a string representation.
Take a look at this example:
>>> class X():
... def x(self):
... pass
...
>>> a = X()
>>> print str(a)
<__main__.X instance at 0x7f8fe13d4b00>
>>> print "this is a string: %s." % a
this is a string: <__main__.X instance at 0x7f8fe13d4b00>.
> But I'm not worry about it.
> IMO, no one will not pass this instance of object to KimchiException
> as args.
IMO, we should never trust that the users/developers will pass the
correct parameters to our code. Eventually, someone will forget that,
and then we will have one more bug ;)
--
Thanks and best regards!
Sheldon Feng(???)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center