Commit 49514a19 authored by Kirill Smelkov's avatar Kirill Smelkov

Assert that ver != ø in addbom

This emits useful information instead of further crash if an url could
not be parsef successfully as e.g. in below.

Before the patch:

    Traceback (most recent call last):
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 434, in <module>
        main()
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 423, in main
        bom = bom_software(arg)
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 108, in bom_software
        addbom(geturl(part), '')    # XXX detect kind?
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 56, in addbom
        ver = removeprefix(ver, name+'-')   # wendelin.core-2.0.alpha3-0-g6315384  -> 2.0.alpha3-0-g6315384
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 384, in removeprefix
        if s.startswith(prefix):
    AttributeError: 'NoneType' object has no attribute 'startswith'

After the patch:

    Traceback (most recent call last):
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 435, in <module>
        main()
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 424, in main
        bom = bom_software(arg)
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 109, in bom_software
        addbom(geturl(part), '')    # XXX detect kind?
      File "/srv/slapgrid/slappart5/srv/project/nxd-bom/nxdbom/__init__.py", line 56, in addbom
        assert ver is not None, urlpath
    AssertionError: https://github.com/unicode-org/icu/releases/download/release-58-2/icu4c-58_2-src.tgz
parent 7586c2ae
......@@ -53,6 +53,7 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
if version is not None:
assert ver is None
ver = version
assert ver is not None, urlpath
ver = removeprefix(ver, name+'-') # wendelin.core-2.0.alpha3-0-g6315384 -> 2.0.alpha3-0-g6315384
if '//' in urlpath:
url = urlpath
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment