def find_module(fullname, path): """Compatibility wrapper for imp.find_module. Automatically decodes arguments of find_module, in Python3 they must be Unicode """ if isinstance(fullname, bytes): fullname = fullname.decode() if isinstance(path, bytes): path = path.decode() elif isinstance(path, list): newpath = [] for element in path: if isinstance(element, bytes): newpath.append(element.decode()) else: newpath.append(element) path = newpath return original_find_module(fullname, path)