[PATCH] _readRawRepoFile: return only valid (ini, section_id). BZ 1018795

James Antill james at fedoraproject.org
Mon Nov 4 19:44:33 UTC 2013


On Mon, 2013-11-04 at 16:55 +0100, Zdenek Pavlas wrote:
> Apparently we may loop over all sections without a match and
> return section_id that's not defined.  Return None instead.

 Something very weird is going on here ...

> ---
>  yum/config.py | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/yum/config.py b/yum/config.py
> index 17aa0ca..df24900 100644
> --- a/yum/config.py
> +++ b/yum/config.py
> @@ -1224,6 +1224,9 @@ def _readRawRepoFile(repo):
>          for sect in ini._sections.keys():
>              if varReplace(sect, repo.yumvar) == repo.id:
>                  section_id = sect
> +                break
> +        else:
> +            return None

 This means that we've opened repo.repofile, but can't find a section
matching repo.id in that file. About the only way I can think of that
happening is for something to rewrite the file between yum first opening
it and yum reopening it to get the raw data, or maybe having a repo.id
containing $vars, and changing those vars after repo. loading. Both of
which would be in the "don't do that, then" bucket.
 I guess returning None is the best we can do (about the only other
option is a big deathly exception), so ACK, but we should put a giant
comment in saying "give up hope all ye who try to understand how we hit
this"

>      return ini, section_id
>  
>  def writeRawRepoFile(repo,only=None):




More information about the Yum-devel mailing list