[elbe-devel] [PATCH] licencexml: Catch spurious exception

Bastian Germann bage at linutronix.de
Mon Jun 22 19:25:54 CEST 2020


Am 22.06.20 um 19:13 schrieb Olivier Dion:
> Getters of the cc variable can throw exceptions.  Thus, moved the list
> of files creation in the try region.
> 
> Traceback:
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/var/cache/elbe/devel/elbepack/asyncworker.py", line 194, in execute
>     skip_pbuild=self.skip_pbuilder)
>   File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 654, in build
>     [p.name for p in cache.get_installed_pkgs()])
>   File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 1052, in
> gen_licenses
>     env.rfs.write_licenses(f, pkg_list, lic_xml_fname)
>   File "/var/cache/elbe/devel/elbepack/efilesystem.py", line 217, in
> write_licenses
>     licence_xml.add_copyright_file(pkg, lic_text)
>   File "/var/cache/elbe/devel/elbepack/licencexml.py", line 82, in
> add_copyright_file
>     files.append((cc.files, cc.license.synopsis, cc.copyright))
>   File "/usr/lib/python2.7/dist-packages/debian/deb822.py", line 2092,
> in getter
>     return field.from_str(val)
>   File "/usr/lib/python2.7/dist-packages/debian/copyright.py", line 436,
> in from_str
>     lines = parse_multiline_as_lines(s)
>   File "/usr/lib/python2.7/dist-packages/debian/copyright.py", line 408,
> in parse_multiline_as_lines
>     'continued line must begin with " "')
> MachineReadableFormatError: continued line must begin with " "
> ----------------------------------------------------------------------
> 
> Reported-by: Bastian Germann <bage at linutronix.de>
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Bastian Germann <bage at linutronix.de>

> ---
>  elbepack/licencexml.py | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
> index f9a748b5..8fb2b92d 100644
> --- a/elbepack/licencexml.py
> +++ b/elbepack/licencexml.py
> @@ -70,17 +70,19 @@ class copyright_xml (object):
>                                                       errors='replace'))
>          try:
>              c = Copyright(bytesio, strict=True)
> -        except (NotMachineReadableError, MachineReadableFormatError) as E:
> -            logging.warning("Error in copyright of package '%s': %s", pkg_name, E)
> -        except Warning as W:
> -            logging.warning("Warning in copyrigh of package '%s' : %s", pkg_name, W)
> -        else:
>  
>              files = []
>  
> +            # Note!  Getters of cc can throw nasty exceptions!
>              for cc in c.all_files_paragraphs():
>                  files.append((cc.files, cc.license.synopsis, cc.copyright))
>  
> +        except (NotMachineReadableError, MachineReadableFormatError) as E:
> +            logging.warning("Error in copyright of package '%s': %s", pkg_name, E)
> +        except Warning as W:
> +            logging.warning("Warning in copyrigh of package '%s' : %s", pkg_name, W)
> +        else:
> +
>              xmlpkg.append('machinereadable')
>              xmllic = xmlpkg.append('debian_licenses')
>              seen = []
> 



More information about the elbe-devel mailing list