Skip to content

Fix opening XBM images with arbitrary array names - #10088

Draft
teachershuang wants to merge 1 commit into
python-pillow:mainfrom
teachershuang:hongkaigu/xbm-array-name
Draft

teachershuang wants to merge 1 commit into
python-pillow:mainfrom
teachershuang:hongkaigu/xbm-array-name

Conversation

@teachershuang

@teachershuang teachershuang commented Sep 30, 2026 •

Copy link
Copy Markdown

Fixes #10087 (the array-name report).

Changes proposed in this pull request:

  • Preserve the existing _bits parsing, and otherwise accept a C identifier for an initialized bitmap array.
  • Skip header comments in the fallback search without consuming subsequent arrays or changing the decoder offset.
  • Add decoded-pixel regressions, compatibility cases and a release note. Leading comments before the size definitions remain a separate format-detection issue.

Validation for 58e441a on Windows, CPython 3.12.14, a native current-main core/zlib build:

  • python3 selftest.py: 59 passed.
  • XBM tests with pytest-cov: 41 passed; the plugin has 100% statement/branch coverage (40 statements, 8 branches). The same tests on unmodified main give 19 failures and 22 passes.
  • Touched-file and whole-repository pre-commit checks passed; Sphinx HTML build with --fail-on-warning passed.
  • Pinned mypy passed for the changed files and all 302 files with --platform linux. The default Windows tox command reports 19 errors in 8 unchanged files.
  • The local full test-suite attempt stopped after 10 missing-JPEG failures: 663 passed, 470 skipped. The unmodified main core reproduces the same failures. This local environment limitation is separate from the successful upstream platform/codec CI below.

AI-assisted implementation and testing. The completed independent full-diff Codex review found no remaining actionable defects.

CI update (October 1, 58e441a): all 56 current checks succeeded, including platform tests, lint, docs, benchmarks and Codecov patch/project. A maintainer reran the macOS Python 3.13 job: the previously failing truncated-PNG leak test now passes; that job completed with 5684 passed, 48 skipped and 3 xfailed. No code or test expectations were changed to clear it. Draft still awaits maintainer direction on permissive array-name compatibility versus Xlib's stricter reader and the reporter's producer details, discussed in #10087.

Signed-off-by: teachershuang <guhongkaiailaopo@gmail.com>
@teachershuang

Copy link
Copy Markdown
Author

Thanks for approving the workflows. At 58e441a, the only failing test job is macOS Python 3.13: Tests/test_file_png.py::TestTruncatedPngPLeaks::test_leak_load exceeds its RSS-growth threshold at iteration 56 (3616 KiB versus a 2048 KiB limit). The run reports 4270 passed, 41 skipped and 3 xfailed before stopping.

The PNG loader, leak test/helper and native decoder are unchanged. The same test on the PR's baseline 9d307290, macOS Python 3.13 passed. This is not proof that the current failure is cleared or harmless. My Windows rerun gives 41 XBM tests passed with 100% statement/branch coverage; the PNG leak test is skipped on Windows, so I cannot verify the macOS failure locally.

Could a maintainer rerun the failed macOS job? My rerun attempt requires repository admin rights. Other current checks, including Codecov patch/project, pass; I am keeping this Draft pending the failing job and the reference-implementation discussion in #10087. No code or test expectations changed to hide the failure.

@radarhere

Copy link
Copy Markdown
Member

I've rerun the failing test, and it has succeeded now.

This branch has not been deployed

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

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XBM loader is too strict on variable name

2 participants