80c7eff python: Streamline hosts_to_list

Authored and Committed by nsoffer 4 years ago
    python: Streamline hosts_to_list
    
    This function used error prone style, using local loop variable in the
    scope of the function, making cleanup more risky.
    
    Move ls_entry info the loop scope, and use PyList_SetItem(), stealing
    the reference to ls_entry, so we need to decrease the reference count
    only on errors.
    
    To use PyList_SetItem() we need to allocate the entire list upfront,
    which is good idea anyway.
    
    While refactoring, remove some useless and wrong comments.
    
    Signed-off-by: Nir Soffer <nsoffer@redhat.com>
    
        
file modified
+13 -18