• Kirill Smelkov's avatar
    Assert that ver != ø in addbom · 49514a19
    Kirill Smelkov authored
    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
    49514a19
__init__.py 16.9 KB