Skip to content

Raise ParseError, not StopIteration, from readOne on an empty stream - #145

Merged
da4089 merged 1 commit into
py-vobject:masterfrom
eeshsaxena:fix/readone-empty-stream
Aug 16, 2026
Merged

Raise ParseError, not StopIteration, from readOne on an empty stream#145
da4089 merged 1 commit into
py-vobject:masterfrom
eeshsaxena:fix/readone-empty-stream

Conversation

@eeshsaxena

Copy link
Copy Markdown

vobject.readOne('') (or any whitespace-only input) raises a bare StopIteration instead of a ParseError:

import vobject
vobject.readOne('')
# StopIteration

readOne returns next(readComponents(...)), and an empty or whitespace-only stream yields no components, so next() raises StopIteration straight out of readOne. I catch it and raise ParseError instead, consistent with how the other malformed-input cases are reported.

Added a test_empty_stream next to test_bad_stream; it raises StopIteration on master and passes with the change, and the parsing suite still passes. Found it by fuzzing readOne.

readOne returns next(readComponents(...)). An empty or whitespace-only stream
produces no components, so next() raised a bare StopIteration out of readOne.
Catch it and raise ParseError instead.
@da4089
da4089 self-requested a review August 16, 2026 00:39
@da4089

da4089 commented Aug 16, 2026

Copy link
Copy Markdown

Looks good.
Thanks for the PR.

@da4089
da4089 merged commit 5535b0f into py-vobject:master Aug 16, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants