Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration.dump raises StopIteration if the last line is empty. #148

Open
tkorvola opened this issue Jun 20, 2022 · 3 comments
Open

Configuration.dump raises StopIteration if the last line is empty. #148

tkorvola opened this issue Jun 20, 2022 · 3 comments

Comments

@tkorvola
Copy link

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.

@sampsyo
Copy link
Member

sampsyo commented Jun 22, 2022

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?

@tkorvola
Copy link
Author

Try putting this in config_default.yaml:

foo: 42
# Oops.

@sampsyo
Copy link
Member

sampsyo commented Jun 23, 2022

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…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants