From: Alexander Kanavin <alex.kanavin@gmail.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH] bitbake: fix version comparison when one of the versions ends in .
Date: Sun, 24 Feb 2019 21:07:28 +0100 [thread overview]
Message-ID: <20190224200728.110431-1-alex.kanavin@gmail.com> (raw)
Previously, this would happen:
======================================================================
ERROR: test_vercmpstring (bb.tests.utils.VerCmpString)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alexander/development/poky/bitbake/lib/bb/tests/utils.py", line 45, in test_vercmpstring
result = bb.utils.vercmp_string('1.', '1.1')
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 143, in vercmp_string
return vercmp(ta, tb)
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 135, in vercmp
r = vercmp_part(va, vb)
File "/home/alexander/development/poky/bitbake/lib/bb/utils.py", line 124, in vercmp_part
elif ca < cb:
TypeError: '<' not supported between instances of 'NoneType' and 'int'
----------------------------------------------------------------------
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
bitbake/lib/bb/tests/utils.py | 4 ++++
bitbake/lib/bb/utils.py | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/bitbake/lib/bb/tests/utils.py b/bitbake/lib/bb/tests/utils.py
index 2f4ccf3c62b..f1cd83a4195 100644
--- a/bitbake/lib/bb/tests/utils.py
+++ b/bitbake/lib/bb/tests/utils.py
@@ -42,6 +42,10 @@ class VerCmpString(unittest.TestCase):
self.assertTrue(result < 0)
result = bb.utils.vercmp_string('1.1', '1.0+1.1-beta1')
self.assertTrue(result > 0)
+ result = bb.utils.vercmp_string('1.', '1.1')
+ self.assertTrue(result < 0)
+ result = bb.utils.vercmp_string('1.1', '1.')
+ self.assertTrue(result > 0)
def test_explode_dep_versions(self):
correctresult = {"foo" : ["= 1.10"]}
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 9cb702dbb7a..b652a6838a2 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -121,6 +121,10 @@ def vercmp_part(a, b):
return -1
elif oa > ob:
return 1
+ elif ca is None:
+ return -1
+ elif cb is None:
+ return 1
elif ca < cb:
return -1
elif ca > cb:
--
2.17.1
reply other threads:[~2019-02-24 20:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190224200728.110431-1-alex.kanavin@gmail.com \
--to=alex.kanavin@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox