`Configuration.dump` raises `StopIteration` if the last line is empty.
yaml_util.restore_yaml_comments has an explicit call to next without catching StopIteration, which is raised if the last processed line is empty or a comment. This seems to happen in Configuration.dump if the last line of config_default.yaml is empty or a comment.
Aha, that's annoying! Any chance you have a test input you could provide so we can craft a fix and a test to make sure we don't reintroduce this?
Try putting this in config_default.yaml:
foo: 42
# Oops.
Thanks!!
It turns out that writing tests for this is surprisingly annoying, given the hard-coded way we have of relying on the default source to exclude default options. I gave it a start in the test-dump branch:
https://github.com/beetbox/confuse/tree/test-dump
…but in case anyone is following along here, I would love some help bringing this to completion so we can test for this behavior.
Also worth noting that #52 could hopefully sidestep this by switching to a proper/robust round-tripping YAML library…