# Buggy code
def _get_instances_from_children(self, child):
    instances = []

    if hasattr(child, "childEntity"):
        self.debugl("CHILDREN: %s" % str(child.childEntity))
        instances += self._get_instances_from_children(child.childEntity)
    elif hasattr(child, "vmFolder"):
        self.debugl("FOLDER: %s" % str(child))
        instances += self._get_instances_from_children(child.vmFolder)
    elif hasattr(child, "index"):
        self.debugl("LIST: %s" % str(child))
        for x in sorted(child):
            self.debugl("LIST_ITEM: %s" % x)
            instances += self._get_instances_from_children(x)
    elif hasattr(child, "guest"):
        self.debugl("GUEST: %s" % str(child))
        instances.append(child)
    elif hasattr(child, "vm"):
        # resource pools
        self.debugl("RESOURCEPOOL: %s" % child.vm)
        if child.vm:
            instances += self._get_instances_from_children(child.vm)
    else:
        self.debugl("ELSE ...")
        try:
            self.debugl(child.__dict__)
        except Exception as e:
            pass
        self.debugl(child)
    return instances


# Traceback (UnicodeEncodeError)
./vmware_inventory.py --list
Traceback (most recent call last):
File "./vmware_inventory.py", line 568, in <module>
print(VMWareInventory().show())
File "./vmware_inventory.py", line 109, in __init__
self.do_api_calls_update_cache()
File "./vmware_inventory.py", line 147, in do_api_calls_update_cache
instances = self.get_instances()
File "./vmware_inventory.py", line 282, in get_instances
instances = self._get_instances(kwargs)
File "./vmware_inventory.py", line 307, in _get_instances
ifacts = self.facts_from_vobj(instance)
File "./vmware_inventory.py", line 514, in facts_from_vobj
rdata[method] = self._process_object_types(methodToCall, level=level)
File "./vmware_inventory.py", line 545, in _process_object_types
md = self.facts_from_vobj(vobj, level=(level+1))
File "./vmware_inventory.py", line 487, in facts_from_vobj
rdata[k] = self._process_object_types(v, level=level)
File "./vmware_inventory.py", line 523, in _process_object_types
self.debugl("PROCESSING: %s" % str(vobj))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0159' in position 205: ordinal not in range(128)

# Fixed code
def _get_instances_from_children(self, child):
    instances = []

    if hasattr(child, "childEntity"):
        self.debugl("CHILDREN: %s" % child.childEntity)
        instances += self._get_instances_from_children(child.childEntity)
    elif hasattr(child, "vmFolder"):
        self.debugl("FOLDER: %s" % child)
        instances += self._get_instances_from_children(child.vmFolder)
    elif hasattr(child, "index"):
        self.debugl("LIST: %s" % child)
        for x in sorted(child):
            self.debugl("LIST_ITEM: %s" % x)
            instances += self._get_instances_from_children(x)
    elif hasattr(child, "guest"):
        self.debugl("GUEST: %s" % child)
        instances.append(child)
    elif hasattr(child, "vm"):
        # resource pools
        self.debugl("RESOURCEPOOL: %s" % child.vm)
        if child.vm:
            instances += self._get_instances_from_children(child.vm)
    else:
        self.debugl("ELSE ...")
        try:
            self.debugl(child.__dict__)
        except Exception as e:
            pass
        self.debugl(child)
    return instances