Skip to content

Unguarded ExpatParser.flush() logs a spurious warning on Python < 3.10.14 #2119

Description

@janbuchar

_XmlSitemapParser.flush calls self._parser.flush() unguarded.

  • ExpatParser.flush isn't part of the documented IncrementalParser interface and doesn't exist before 3.10.14 - verified False on 3.10.0 / 3.10.8 / 3.10.12 / 3.10.13, True on 3.10.14+, all of which satisfy our requires-python = ">=3.10"
  • consequence on those interpreters: every sitemap parse logs Failed to parse remaining XML data: 'ExpatParser' object has no attribute 'flush' at WARNING
  • not data loss - flush() contributes 0 items in every scenario I tried (single chunk, 3 chunks, truncated document, 20k <url> entries fed in 1 KiB slices cutting tokens mid-token). Expat's reparse deferral landed in the same release as flush(), so on interpreters without flush() nothing is ever left buffered
  • so: pure log noise, low priority. Guard with suppress(AttributeError) / getattr, or drop the call
  • separately, the except swallows the yield loop below it - if flush() ever did raise with items buffered, they'd be discarded. Cheap to make robust by yielding self._handler.items in a finally

Activity

  1. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Aug 4, 2026
  2. added a commit that references this issue on Aug 11, 2026
    7f75295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions