libdnf
libdnf copied to clipboard
Difference in comment parsing
#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.
Thanks for the report. We should definitely at least document the behavior.