renatopp / liac-arff

A library for read and write ARFF files in Python
MIT License
99 stars 49 forks source link

Fix for Python 4 #98

Closed hugovk closed 5 years ago

hugovk commented 5 years ago

We don't yet know if 3.10 or 4.0 will follow Python 3.9, but whichever it is, it will probably happen in 2020 when Python 3.9 reaches beta.

There's some code which checks the Python major version is exactly 3:

PY3 = sys.version_info[0] == 3
if PY3:
    # Python 3+ code

...

conversors = [ConversorStub(str if arff.PY3 else unicode),
              ConversorStub(float),
              ConversorStub(int),
              ConversorStub(str if arff.PY3 else unicode)]

When run on Python 4, this will run the Python 2 code! Instead, check the version is >= 3.

Found using https://github.com/asottile/flake8-2020:

$ pip install -U flake8-2020
...
$ flake8 --select YTT
./arff.py:307:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=`