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

Clarify that load_all methods return a generator, not a sequence #18

Open
mpitt opened this issue Nov 8, 2023 · 0 comments
Open

Clarify that load_all methods return a generator, not a sequence #18

mpitt opened this issue Nov 8, 2023 · 0 comments

Comments

@mpitt
Copy link

mpitt commented Nov 8, 2023

The documentation for load_all and safe_load_all states (emphasis mine):

... returns a sequence of Python objects ...

In reality, those methods return a generator, which is not the same thing as a sequence. For example:

with open(filename) as f:
    docs = yaml.safe_load_all(f)
for d in docs:
    # do stuff

will raise ValueError: I/O operation on closed file. which if docs was really a sequence doesn't make sense.

(Moved from yaml/pyyaml#762)

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

1 participant