Skip to content

Accept binary file-like SQL streams - #925

Open
adenzhou1350 wants to merge 1 commit into
andialbrecht:masterfrom
adenzhou1350:codex/binary-sql-streams
Open

adenzhou1350 wants to merge 1 commit into
andialbrecht:masterfrom
adenzhou1350:codex/binary-sql-streams

Conversation

@adenzhou1350

Copy link
Copy Markdown

Fixes #352.

parsestream currently accepts text streams and raw bytes, but rejects binary file-like objects such as BytesIO and GzipFile before reaching its existing byte-decoding logic. Accept IOBase streams and update the public annotation/docstring; keep decoding, statement grouping, error propagation and stream ownership unchanged.

Tests cover plain/gzip streams with UTF-8 and explicit Latin-1, default UTF-8 decoding, text streams, invalid encodings and unsupported input objects. Six regression cases fail on unchanged master; all eight pass with this change.

Local validation on Windows / CPython 3.14.3:

  • Full native suite: 514 passed, 2 xfailed, 1 xpassed. Unchanged master has 506 passed with the same xfail/xpass results.
  • python -B -m ruff check sqlparse/ and git diff --check: pass.

This does not add incremental/chunked input processing: streams are still read by the existing lexer path. Linux and maintainer CI have not been run locally.

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.

parsestream doesn't accept GzipFile

1 participant