Skip to content

fix: struct reads any buffer; sys1's name check takes x-python - #246

Open
jonruttan wants to merge 1 commit into
mainfrom
fix/struct-buffers-sys1
Open

jonruttan wants to merge 1 commit into
mainfrom
fix/struct-buffers-sys1

Conversation

@jonruttan

Copy link
Copy Markdown
Owner

Conformance: struct_endian and sys1.

  • struct (python/struct.x): unpack and unpack_from took bytes only, so a memoryview, bytearray or array was refused with "a buffer is required". They now read any buffer through python-buffer-bytes. Anything else raises CPython's TypeError, a bytes-like object is required, not 'str'. tests/specs/99-struct.spec.md gains a case covering each buffer kind and the refusal.
  • sys1 (tools/conformance/gen-specs.py): the case checks sys.implementation.name in ('cpython', 'micropython'). x-python reporting its own name conforms, so a new ADAPTED table widens that check to take 'x-python'. Only the case's source changes: CPython answers the widened check as before, so its run stays the oracle. Each adaptation is listed under "adapted" in SKIPPED.md, and the generator stops if an adapted text is no longer in its file.

class_store_class, the third case looked at, already passes on v0.59.0.

Tests: the full suite passes locally on x-lang v0.59.0. struct_endian and the regenerated sys1 pass. Regenerating basics gives the same 532 cases.

🤖 Generated with Claude Code

struct.unpack and unpack_from read bytes only, so a memoryview, a
bytearray or an array was refused with "a buffer is required"
(struct_endian).  They now read any buffer through python-buffer-bytes,
and anything else is CPython's TypeError, "a bytes-like object is
required, not 'str'".

sys1 asks whether sys.implementation.name is 'cpython' or 'micropython'.
x-python reporting its own name conforms, so gen-specs.py gains an
ADAPTED table that widens that check to take 'x-python'.  CPython
answers the widened check as before, so its run stays the oracle, and
each adaptation is listed in SKIPPED.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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