Skip to content

Iterator passed as append_middleware/prepend_middleware is silently dropped #531

@MiWeiss

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions