[Yum-devel] [PATCH] in python 3k (and in the new rpm-python bindings) rpm is returning flags as LONGS not INTS - so this code breaks w/o this fix.
Mike Bonnet
mikeb at redhat.com
Tue Jun 1 17:42:41 UTC 2010
On 06/01/2010 01:36 PM, Mike Bonnet wrote:
> On 06/01/2010 01:30 PM, Tim Lauridsen wrote:
>> On Tue, Jun 1, 2010 at 7:13 PM, Seth Vidal <skvidal at fedoraproject.org>wrote:
>>
>>> most importantly it breaks mock
>>> ---
>>> rpmUtils/miscutils.py | 2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/rpmUtils/miscutils.py b/rpmUtils/miscutils.py
>>> index 8e46541..b1631ae 100644
>>> --- a/rpmUtils/miscutils.py
>>> +++ b/rpmUtils/miscutils.py
>>> @@ -351,7 +351,7 @@ def formatRequire (name, version, flags):
>>> '''
>>> s = name
>>>
>>> - if flags and type(flags) == type(0): # Flag must be set and a int
>>> + if flags and (type(flags) == type(0) or type(flags) == type(0L)): #
>>> Flag must be set and a int (or a long, now)
>>> if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER |
>>> rpm.RPMSENSE_EQUAL):
>>> s = s + " "
>>> --
>>> 1.7.0.1
>>>
>>> _______________________________________________
>>> Yum-devel mailing list
>>> Yum-devel at lists.baseurl.org
>>> http://lists.baseurl.org/mailman/listinfo/yum-devel
>>>
>>
>>
>> what about
>>
>> if flags and (isinstance(flags,int ) or isinstance(flags,long): #
>>
>> more readable, but no problems with your version :)
>
> isinstance() accepts a tuple of class or type objects as the second
> parameter:
>
> if flags and isinstance(flags, (int, long)): #
Actually, since 0 is probably a valid flags value, it might make sense
to get rid of the first test, and just leave it as:
if isinstance(flags, (int, long)): #
That will also filter out any occurrences of flags == None.
More information about the Yum-devel
mailing list