Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-88528

distutils.version LooseVersion class breaks with kernel versioning

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Undefined Undefined
    • None
    • rhel-8.10
    • python3
    • None
    • No
    • Moderate
    • rhel-pt-python
    • ssg_platform_tools
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      Comparing versions of kernel packages below fail with a traceback:

      # /usr/libexec/platform-python3.6
      [...]
      >>> from distutils.version import LooseVersion
      >>> a = LooseVersion("4.18.0-553.47.1.el8_10.x86_64")
      >>> a.version
      [4, 18, 0, '-', 553, 47, 1, 'el', 8, '_', 10, 'x', 86, '_', 64]
      
      >>> b = LooseVersion("4.18.0-553.el8_10.x86_64")
      >>> b.version
      [4, 18, 0, '-', 553, 'el', 8, '_', 10, 'x', 86, '_', 64]
      
      >>> a < b
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/lib64/python3.6/distutils/version.py", line 52, in __lt__
          c = self._cmp(other)
        File "/usr/lib64/python3.6/distutils/version.py", line 337, in _cmp
          if self.version < other.version:
      TypeError: '<' not supported between instances of 'int' and 'str'
      

      The root cause is item 5, which is a string in b ("el") versus an int in a ("47").

              python-maint python-maint
              rhn-support-rmetrich Renaud Métrich
              python-maint python-maint
              Lukas Zachar Lukas Zachar
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: