invalid version number '%s'
Package:
ansible
49704

Exception Class:
ValueError
Raise code
version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
RE_FLAGS)
def parse(self, vstring):
match = self.version_re.match(vstring)
if not match:
raise ValueError("invalid version number '%s'" % vstring)
(major, minor, patch, prerelease, prerelease_num) = \
match.group(1, 2, 4, 5, 6)
if patch:
self.version = tuple(map(int, [major, minor, patch]))
else:
🙏 Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too!
We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Links to the raise (1)
https://github.com/ansible/ansible/blob/015331518dff60f31a7d8ce24fc315e3ac9e86f8/lib/ansible/module_utils/compat/version.py#L143Ways to fix
The exception is thrown when calling StrictVersion.
StrictVersion is version numbering. A version number consists of two or three dot-separated numeric components, with an optional "pre-release" tag on the end. The pre-release tag consists of the letter 'a' or 'b' followed by a number.
When you are using invalid version numbers, you will get an error.
Here is some invalid version numbers example:
1 2.7.2.2 1.3.a4 1.3pl1 1.3c4
To reproduce an error
from distutils.version import StrictVersion
version = StrictVersion('1.3.a4')
print(version)
Fix code:
from distutils.version import StrictVersion
version = StrictVersion('0.9.6')
print(version)
Add a possible fix
Please authorize to post fix