Skip to content

Fix empty content inspection falling back to a file path - #383

Open
pacocartones wants to merge 1 commit into
python-excel:masterfrom
pacocartones:fix/inspect-empty-content
Open

pacocartones wants to merge 1 commit into
python-excel:masterfrom
pacocartones:fix/inspect-empty-content

Conversation

@pacocartones

@pacocartones pacocartones commented Oct 20, 2026 •

Copy link
Copy Markdown

When inspect_format(content=b'') receives empty bytes, it treats them as omitted content. With no path this raises TypeError; with an XLSX path it inspects that file instead and returns 'xlsx'. Distinguish None from empty bytes so unknown empty content returns None and supplied content retains priority.

This changes one production line and adds two regression tests. Both tests fail on unchanged master (d8302dc39b16c03d643ef1eee89605c2e007ed2b) and pass with the fix. Validation on Python 3.12.3, Linux/WSL: python -m pytest -q tests/test_inspect.py tests/test_open_workbook.py — 14 passed. git diff --check passes. The full suite and platform matrix were not run.

Scope: this fixes inspect_format only. It does not fix all handling of open_workbook(file_contents=b''), which has separate fallback logic in book.py. Related historical context: #55 discussed the same distinction in the older open_workbook implementation and was closed without follow-up.

@cjw296

cjw296 commented Oct 20, 2026

Copy link
Copy Markdown
Member

What's your intention here? This library hasn't had a release in years and no longer supports xlsx.

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.

2 participants