Skip to content

fix(sitemap): guard the unavailable ExpatParser.flush on older CPython patch releases - #2141

Open
Mantisus wants to merge 1 commit into
apify:masterfrom
Mantisus:sitemap-flush-fix
Open

fix(sitemap): guard the unavailable ExpatParser.flush on older CPython patch releases#2141
Mantisus wants to merge 1 commit into
apify:masterfrom
Mantisus:sitemap-flush-fix

Conversation

@Mantisus

@Mantisus Mantisus commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Description

  • _XmlSitemapParser.flush called ExpatParser.flush() unguarded. The method was added in CPython 3.10.14, 3.11.9, and 3.12.3, so on earlier patch releases every sitemap parse logged a spurious WARNING. It's now called only when it exists.
  • Moved the yield loop into a finally, so a raising flush() no longer discards the items the handler has already collected.

Issues

Testing

  • Added tests for a parser without flush and for a failing flush().

@Mantisus Mantisus self-assigned this Aug 7, 2026
@Mantisus
Mantisus requested a review from vdusek August 7, 2026 18:09
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.

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

2 participants