libdnf icon indicating copy to clipboard operation
libdnf copied to clipboard

Difference in comment parsing

Open rowlap opened this issue 1 year ago • 1 comments

#1484 was closed last year, but I think there's a difference worth documenting in the comment syntax.

$ cat dnf.conf
[main]

excludepkgs =
  # packages we don't want
  nginx

$ python3 -c "import configparser; c = configparser.ConfigParser(); c.read('dnf.conf'); print(dict(c.items('main')))"
{'excludepkgs': '\nnginx'}


$ dnf -v --config dnf.conf help | grep Exclude
Excludes in dnf.conf: #, don't, nginx, packages, want, we

The code in libdnf IniParser only considers comments to begin in column 0.

For a boolean/int option this is more obvious as trailing comments will be invalid, but for list options it's an easy trap to fall in to (guess why I'm filing this issue).

Please either document the libdnf comment syntax, or change the parser to align with python configparser, and even then it's still worth documenting.

rowlap avatar Dec 13 '23 22:12 rowlap

Thanks for the report. We should definitely at least document the behavior.

jan-kolarik avatar Dec 19 '23 09:12 jan-kolarik