PasaOpasen / toml-union

Script to union several *.toml files (usually Poetry pyproject.toml) to simplify manual dependences resolving
MIT License
10 stars 1 forks source link

toml_union.py: Check values size in process() #2

Closed clupuishere closed 8 months ago

clupuishere commented 8 months ago

When trying to merge Cargo.toml files for rust we get the following traceback:

Traceback (most recent call last):
  File "./toml-union/myscript.py", line 7, in <module>
    toml_union_process(
  File "./toml-union/toml_union.py", line 406, in toml_union_process
    datas: DATA_DICT = union_dicts(
  File "./toml-union/toml_union.py", line 299, in union_dicts
    dicts = [
  File "./toml-union/toml_union.py", line 299, in <listcomp>
    dicts = [
  File "./toml-union/toml_union.py", line 407, in <genexpr>
    read_toml(file) for file in toml_files
  File "./toml-union/toml_union.py", line 210, in read_toml
    content = disable_lists_dict(content)
  File "./toml-union/toml_union.py", line 175, in disable_lists_dict
    return process(dct)
  File "./toml-union/toml_union.py", line 171, in process
    d[k] = process(v)
  File "./toml-union/toml_union.py", line 162, in process
    if isinstance(v, list) and isinstance(v[0], dict):  # it is the list of dicts
IndexError: list index out of range

Checking the values size in process() fixes that.

PasaOpasen commented 8 months ago

Very good