votes up 3

invalid version number '%s'

github stars 49704
Exception Class:

Raise code

    version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',

    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) = \
  , 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(int, [major, minor, patch]))
ūüôŹ 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.

Ways to fix

votes up 1 votes down

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:


To reproduce an error

from distutils.version import StrictVersion

version = StrictVersion('1.3.a4')

Fix code:

from distutils.version import StrictVersion

version = StrictVersion('0.9.6')
Jul 27, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix