On Mon, 2014-02-03 at 13:38 +0100, David Shea wrote:
On 02/03/2014 01:29 PM, Vratislav Podzimek wrote:
> On Mon, 2014-02-03 at 10:45 +0100, David Shea wrote:
>> The return value of Size.humanReadable is sometimes a unicode, since the
>> translated units need to be unicode in order for upper/lower to work.
>> Convert the value back to a str so that __str__ conversions don't get
>> confused.
>> ---
>> blivet/size.py | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/blivet/size.py b/blivet/size.py
>> index e7b6d30..dd19201 100644
>> --- a/blivet/size.py
>> +++ b/blivet/size.py
>> @@ -207,7 +207,7 @@ class Size(Decimal):
>> return self
>>
>> def __str__(self, context=None):
>> - return self.humanReadable()
>> + return str(self.humanReadable())
>>
>> def __repr__(self):
>> return "Size('%s')" % self
> Is it okay to just call str() on those unicode objects? Or do we need
> decode("utf-8")?
>
You're right, that doesn't work. It has to be encode('utf-8'), though.
Yeah, those two are my dear friends I always confuse with each other.
Even though their names make sense. Well, ACK with the encode("utf-8")
change.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic