From 830c7930434870faa193e780f71427d7024066fb Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 13 Mar 2017 16:06:03 +0000 Subject: [PATCH] We must also override `_cmd` to properly instantiate our version class --- salt/utils/versions.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/salt/utils/versions.py b/salt/utils/versions.py index a7d8521064..0877fe13e3 100644 --- a/salt/utils/versions.py +++ b/salt/utils/versions.py @@ -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)