Skip to content

Decode binary file contents before detecting frontmatter - #139

Open
vitalivo wants to merge 1 commit into
eyeseast:mainfrom
vitalivo:fix/binary-file-loading
Open

vitalivo wants to merge 1 commit into
eyeseast:mainfrom
vitalivo:fix/binary-file-loading

Conversation

@vitalivo

Copy link
Copy Markdown

This replaces #138, which was accidentally closed and its source fork deleted. The implementation is unchanged; the original discussion and reviews remain linked there.


load(BytesIO(...)) and load() on a file opened in binary mode raise TypeError: cannot use a string pattern on a bytes-like object. Format detection runs on the raw bytes before loads() can decode them.

Delegate format detection to loads(), which already decodes with the supplied encoding and respects an explicit handler. Tests cover UTF-8 and UTF-16 byte streams, a binary JSON-frontmatter file, metadata defaults, and a text-stream control.

Validation: the three binary cases fail before the fix; all 69 tests and doctests pass afterward, and mypy . passes.

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.

1 participant