Bug#886963: Diffoscope: different readelf implementations cause version parsing errors on FreeBSD

Guangyuan Yang ygy at freebsd.org
Tue Jan 16 05:05:21 UTC 2018

2018-01-12 2:36 GMT-05:00 Chris Lamb <lamby at debian.org>:
> [Re-adding the bug to CC - please retain in future]
> Hi Guangyuan,
>> The error still exists
> This should fix it:
>   https://anonscm.debian.org/git/reproducible/diffoscope.git/commit/?id=304660a54a433ff65ce0cef986b22b3d76793ab0

Hi Chris,

It still exists. Here is some investigation inside decorator

platform freebsd11 -- Python 3.6.4, pytest-3.2.5, py-1.5.2,
pluggy-0.4.0 -- /usr/local/bin/python3
cachedir: .cache
rootdir: /usr/home/guangyuan/diffoscope, inifile:
collecting 162 items
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
(Pdb) s
> /usr/home/guangyuan/diffoscope/tests/utils/tools.py(47)skip_if_tool_version_is()
-> vcls(str(actual_ver)) == vcls(str(target_ver)),
(Pdb) actual_ver
(Pdb) target_ver
(Pdb) vcls(str(actual_ver))
LooseVersion ('unknown')
(Pdb) vcls(str(target_ver))
LooseVersion ('2.29')
(Pdb) vcls(str(actual_ver)) == vcls(str(target_ver))
*** TypeError: '<' not supported between instances of 'str' and 'int'

When 'unknown' and '2.29' passed in, LooseVersion will fail. Actually,
it seems that LooseVersion does not handle such situation:

➜  ~ python3
Python 3.6.3 (default, Oct  3 2017, 21:45:48)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.version import LooseVersion
>>> LooseVersion('1') == LooseVersion('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/distutils/version.py", line 46, in __eq__
    c = self._cmp(other)
  File "/usr/lib/python3.6/distutils/version.py", line 337, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'int' and 'str'

More information about the Reproducible-builds mailing list