We must also override _cmd to properly instantiate our version class

This commit is contained in:
Pedro Algarvio 2017-03-13 16:06:03 +00:00
parent 0b8a9c44dd
commit 830c793043
No known key found for this signature in database
GPG Key ID: BB36BF6584A298FF

View File

@ -23,13 +23,17 @@ import salt.ext.six as six
class StrictVersion(_StrictVersion):
def parse(self, vstring):
_StrictVersion.parse(self, vstring)
if six.PY3:
# Convert every part of the version to string in order to be able to compare
self.version = [str(vp) for vp in self.version]
def _cmp(self, other):
if isinstance(other, six.string_types):
other = StrictVersion(other)
return _StrictVersion._cmp(self, other)
class LooseVersion(_LooseVersion):
@ -38,3 +42,8 @@ class LooseVersion(_LooseVersion):
if six.PY3:
# Convert every part of the version to string in order to be able to compare
self.version = [str(vp) for vp in self.version]
def _cmp(self, other):
if isinstance(other, six.string_types):
other = LooseVersion(other)
return _LooseVersion._cmp(self, other)