Skip to content

Multibyte delimiters crossing read buffers undercount records and break --update #1847

Description

@xu91102

The CLI does not recognize a multibyte delimiter when it straddles two read buffers. This undercounts records and can crash --update when two numeric records are passed together to literal_eval.

printf '1é2é3' | python -m tqdm --delim 'é' --buf-size 2 --bar-format '{n}it'
# reports 2it, expected 3it
printf '1é2é3' | python -m tqdm --delim 'é' --buf-size 2 --update --bar-format '{n}it'
# SyntaxError while parsing '1é2', expected 6it

posix_pipe searches each fresh chunk before combining it with the saved prefix. Search the combined bytes so split UTF-8 delimiters can match. The stdout payload should remain byte-for-byte unchanged.

Reproduced against master 9cf5a12, Python 3.12.13/macOS. Both public CLI regressions fail before the fix. Investigated with OpenAI Codex assistance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions