ipaplatform.redhat: Use bytestrings when calling rpm.so for version comparison

Part of the work for: https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Petr Viktorin
2016-05-06 17:54:10 +02:00
committed by Martin Basti
parent 9ca450ac43
commit 743828b0f4

View File

@@ -84,13 +84,17 @@ class IPAVersion(object):
def __init__(self, version):
self.version = version
@property
def _bytes(self):
return self.version.encode('utf-8')
def __eq__(self, other):
assert isinstance(other, IPAVersion)
return _librpm.rpmvercmp(self.version, other.version) == 0
return _librpm.rpmvercmp(self._bytes, other._bytes) == 0
def __lt__(self, other):
assert isinstance(other, IPAVersion)
return _librpm.rpmvercmp(self.version, other.version) < 0
return _librpm.rpmvercmp(self._bytes, other._bytes) < 0
class RedHatTaskNamespace(BaseTaskNamespace):