Skip to content

Accept UTF-8 byte-order marks in OBJ and material files - #158

Open
civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/utf8-bom-files
Open

civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/utf8-bom-files

Conversation

@civilwarinfrance

Copy link
Copy Markdown

A UTF-8 byte-order mark at the start of an OBJ or MTL file becomes part of its first statement (v or newmtl). This can omit the first vertex/material, fail face loading, or raise an unimplemented-statement error in strict mode.

Resolve UTF-8 encoding aliases to the standard utf-8-sig decoder when opening plain or gzip files. It consumes only the initial signature; U+FEFF inside a material name remains intact. Keep the requested encoding setting and non-UTF-8 decoding unchanged. Document the behavior.

Validation on macOS/CPython 3.11.15:

  • 24 regression cases fail on the original parser; 28 controls pass.
  • All 143 project tests pass after the change, including 52 new cases for independent OBJ/MTL BOMs, plain/gzip files, default/explicit UTF-8 aliases, strict/non-strict parsing, UTF-16/Latin-1 and interior Unicode characters.
  • CI blocking Flake8 check passes. Advisory check: 210 existing findings versus 211 on the base, no additions. New test file is lint-clean. git diff --check passes.

No dependencies are added. The older CI Python/OS matrix and rendering were not run locally.

AI assistance: OpenAI Codex prepared and tested this contribution.

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.

1 participant