[MERGE] bzrlib.osutils fixes

Dmitry Vasiliev dima at hlabs.spb.ru
Thu Mar 8 08:53:04 GMT 2007

Alexander Belchenko wrote:
> Dmitry Vasiliev пишет:
>> The attached bundle contains small fixes/optimizations for bzrlib.osutils.
> Can you explain this change, please?
>> @@ -704,7 +711,8 @@
>>          for dirdetail, dirblock in osutils._walkdirs_utf8('.'):
>>              self.assertIsInstance(dirdetail[0], str)
>>              if isinstance(dirdetail[1], unicode):
>> -                dirdetail[1] = dirdetail[1].encode('utf8')
>> +                dirdetail = (dirdetail[0], dirdetail[1].encode('utf8'))
>> +                dirblock = [list(info) for info in dirblock]
>>                  for info in dirblock:
>>                      self.assertIsInstance(info[4], unicode)
>>                      info[4] = info[4].encode('utf8')

The changes is a bit straightforward. The old code tried to mutate 
immutable 'dirdetail' and 'info' tuples. The new code recreate 
'dirdetail' tuple and converts all 'info' tuples (there is no real 
difference for them to be lists instead of tuples in the latter code) to 
lists if needed.

Dmitry Vasiliev <dima at hlabs.spb.ru>

More information about the bazaar mailing list