Skip to content

Iterator passed as append_middleware/prepend_middleware is silently dropped #531

Closed

Description

@MiWeiss

The parameters are typed Iterable[Middleware], but _build_parse_stack consumes the iterable when computing append_stack_types before calling list(append_middleware) (bibtexparser/entrypoint.py:36-45; same pattern in _build_unparse_stack, lines 66-75). A generator/iterator therefore results in an empty middleware list — silently.

lib = bibtexparser.parse_string("@article{x, month = {3}}",
    append_middleware=iter([MonthIntMiddleware()]))
lib.entries[0]["month"]  # '3' -- middleware was never applied

Fix: materialize to a list at the top of the builders (or type the params as List).

Activity

  1. claell commented on Jul 16, 2026

    @claell
    Contributor

    I opened draft PR #569 with the focused fix and public parse/write iterator regressions. The branch is based directly on current main and its full test suite passes.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions