Skip to content

version comparison does not work with python 3.10.x due to tuple compare logic. #193

@pruan-rht

Description

@pruan-rht

Running python 3.10.6, I get the import error regarding Iterable. This is due to the fact the tuple comparison is using string comparison which alphabetical.
For example:

In [6]: python_version_tuple() >= ("3", "3", "0")
Out[6]: False

In [7]: python_version_tuple() >= ("3", '3', "0")
Out[7]: False

In [9]: python_version_tuple()
Out[9]: ('3', '10', '6')

In [10]: ('3', '10', '6') > ('3', '9', '6')
Out[10]: False

ImportError: cannot import name 'Iterable' from 'collections' (/home/pruan/.pyenv/versions/3.10.6/lib/python3.10/collections/__init__.py)

I think the solution is to use sys.version_info instead like this:

In [31]:  sys.version_info > (3, 3, 0)
Out[31]: True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions