@@ -371,6 +371,14 @@ def set_config_item(self, key, value):
371
371
except KeyError :
372
372
old_value = None
373
373
374
+ # Get everything to unicode with python2
375
+ if isinstance (value , str ):
376
+ value = value .decode ()
377
+ elif isinstance (value , list ):
378
+ for i in range (len (value )):
379
+ if isinstance (value [i ], str ):
380
+ value [i ] = value [i ].decode ()
381
+
374
382
# Check if it's a list
375
383
def set_key (key , value ):
376
384
self .clear_config_item (key )
@@ -388,13 +396,13 @@ def set_key(key, value):
388
396
if key == "lxc.loglevel" :
389
397
new_value = value
390
398
391
- if (isinstance (value , str ) and isinstance (new_value , str ) and
399
+ if (isinstance (value , unicode ) and isinstance (new_value , unicode ) and
392
400
value == new_value ):
393
401
return True
394
402
elif (isinstance (value , list ) and isinstance (new_value , list ) and
395
403
set (value ) == set (new_value )):
396
404
return True
397
- elif (isinstance (value , str ) and isinstance (new_value , list ) and
405
+ elif (isinstance (value , unicode ) and isinstance (new_value , list ) and
398
406
set ([value ]) == set (new_value )):
399
407
return True
400
408
elif old_value :
@@ -473,7 +481,7 @@ def arch_to_personality(arch):
473
481
Determine the process personality corresponding to the architecture
474
482
"""
475
483
if isinstance (arch , bytes ):
476
- arch = str (arch , 'utf-8' )
484
+ arch = unicode (arch )
477
485
return _lxc .arch_to_personality (arch )
478
486
479
487
# namespace flags (no other python lib exports this)
0 commit comments