[Yum-devel] Re: [yum-cvs] yum/rpmUtils miscutils.py,1.13,1.14

Menno Smits menno-yum at freshfoo.com
Fri Aug 25 07:47:52 UTC 2006


If flagToString() can't interpret the flags ("Umm...now I'm screwed") 
then it should either raise an exception or return a suitable string 
value (eg. "??") as the caller expects a string (or None).

An exception is probably a better option. It is better to fail early so 
that problems are found and fixed rather than staying hidden. There's 
other places in the Yum code that suffer from this issues. Execution 
continues when something odd happens rather than bailing out.

Menno

ps. Useful link related to this kind of thing (examples in Java but 
still useful for any language) 
http://www.martinfowler.com/ieeeSoftware/failFast.pdf


Seth Vidal wrote:
> Update of /home/groups/yum/cvs/yum/rpmUtils
> In directory login1.linux.duke.edu:/tmp/cvs-serv14530/rpmUtils
> 
> Modified Files:
> 	miscutils.py 
> Log Message:
> 
> fix problem in flagToString not handling prereq and rpmsense requires
> correctly
> 
> 
> Index: miscutils.py
> ===================================================================
> RCS file: /home/groups/yum/cvs/yum/rpmUtils/miscutils.py,v
> retrieving revision 1.13
> retrieving revision 1.14
> diff -u -r1.13 -r1.14
> --- miscutils.py	5 Jul 2006 18:43:02 -0000	1.13
> +++ miscutils.py	25 Aug 2006 06:21:43 -0000	1.14
> @@ -300,18 +300,14 @@
>      return s
>      
>  def flagToString(flags):
> -    if flags & rpm.RPMSENSE_EQUAL & rpm.RPMSENSE_GREATER:
> -        return 'GE'
> -    if flags & rpm.RPMSENSE_EQUAL & rpm.RPMSENSE_LESS:
> -        return 'LE'
> -    if flags & rpm.RPMSENSE_EQUAL:
> -        return 'EQ'
> -    if flags & rpm.RPMSENSE_GREATER:
> -        return 'GT'
> -    if flags & rpm.RPMSENSE_LESS:
> -        return 'LT'
> +    flags = flags & 0xf
> +    if flags == 0: return None
> +    if flags == 2: return 'LT'
> +    if flags == 4: return 'GT'
> +    if flags == 8: return 'EQ'
> +    if flags == 10: return 'LE'
> +    if flags == 12: return 'GE'
>  
> -    # Umm...now I'm screwed
>      return flags
>  
>  def stringToVersion(verstring):
> 
> _______________________________________________
> https://lists.dulug.duke.edu/mailman/listinfo/yum-cvs-commits
> 
> Scanned by the NetBox from NetBox Blue
> (http://netboxblue.com/)
> 




More information about the Yum-devel mailing list