Skip to content

fix: handle tabs and repeated spaces in ASCII STL keywords - #258

Open
xgbtxy wants to merge 1 commit into
wolph:developfrom
xgbtxy:fix/ascii-stl-keyword-whitespace
Open

xgbtxy wants to merge 1 commit into
wolph:developfrom
xgbtxy:fix/ascii-stl-keyword-whitespace

Conversation

@xgbtxy

@xgbtxy xgbtxy commented Dec 1, 2026

Copy link
Copy Markdown

Summary

In BaseStl._ascii_reader (stl/stl.py), multi-word ASCII STL keywords are matched against exact single-space byte literals (b'facet normal', b'outer loop', b'end solid'). When a valid ASCII STL file separates those keywords with tabs or multiple spaces (e.g., facet\tnormal\t0 0 1 or outer loop), _ascii_reader raises RuntimeError, causing Mesh.from_file() to fall back to the binary reader and crash with AssertionError on the misread triangle count.

Changes

  • Normalize internal whitespace with b(' ').join(...split()) when matching prefix, endsolid/end solid, outer loop, endloop, and endfacet in BaseStl._ascii_reader.
  • Add test_ascii_keyword_whitespace in tests/test_ascii.py covering tab- and multi-space-separated keywords across both speedups=False and speedups=True.

Verification

  • uv run pytest tests/test_ascii.py tests/test_mesh.py (66 passed, 4 skipped).
  • uv run ruff check stl/stl.py tests/test_ascii.py and uv run ruff format --check stl/stl.py tests/test_ascii.py pass.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants