Skip to content

v0.0.346: pickle.PickleBuffer + compile/exec/eval SyntaxError (v0.1.0 tail)#267

Merged
tamnd merged 1 commit into
mainfrom
feat/v0.0.346-tail-1476
Apr 29, 2026
Merged

v0.0.346: pickle.PickleBuffer + compile/exec/eval SyntaxError (v0.1.0 tail)#267
tamnd merged 1 commit into
mainfrom
feat/v0.0.346-tail-1476

Conversation

@tamnd

@tamnd tamnd commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the v0.1.0 tail items called out in notes/Spec/1400/1476_goipy_v01_prep.md (pickle 5 PickleBuffer, compile()/exec(str)/eval(str), weakref). Spec at notes/Spec/1500/1540_goipy_v0046_tail_pickle5_compile.md.

After this release the v0.1.0 "run any 3.14 .pyc" gate is green.

  • pickle.PickleBuffer class with __init__(bytes-like) / __bytes__ / raw() / release(). Released ops raise ValueError("operation forbidden on released PickleBuffer object") matching CPython.
  • bytes() builtin honors __bytes__ dunder before falling through to the iterable path — required for bytes(PickleBuffer(...)) and any user class that defines __bytes__.
  • compile() / exec(str) / eval(str) raise SyntaxError (previously NotImplementedError) with a clear message that goipy is .pyc-only. User code that catches SyntaxError (the documented compile-time class) now sees the right exception.
  • Interp.New() eagerly calls buildBuiltins() so __import__ / exec / eval / compile are available at the global namespace without needing import builtins first.

Out of scope

  • Actual Python source compilation — gocopy parser is in development; wiring is a separate cycle.
  • weakref GC tracking — Go runtime has no fundamental weak refs; runtime.AddCleanup (Go 1.25+) is achievable but CPython callback ordering makes it real-engineering. Punted post-v0.1.0.
  • Pickle 5 out-of-band buffer round-tripping in pickle.dumps/loads — type exposed but wire-format paths unchanged.

Test plan

  • go test ./... -timeout 600s — green
  • Fixture matches CPython 3.14 byte-for-byte
  • No regression on existing fixtures

… tail)

Closes the v0.1.0 tail items called out in
notes/Spec/1400/1476_goipy_v01_prep.md (pickle 5 PickleBuffer,
compile/exec(str)/eval(str), weakref).

Spec at notes/Spec/1500/1540_goipy_v0046_tail_pickle5_compile.md.

- pickle.PickleBuffer class with __init__(bytes-like)/bytes()/raw()/
  release(); released ops raise ValueError matching CPython.
- bytes() builtin honors __bytes__ dunder before falling through to
  the iterable path — required for bytes(PickleBuffer(...)).
- compile()/exec(str)/eval(str) raise SyntaxError (was
  NotImplementedError) so user code that catches SyntaxError works.
- Interp.New() eagerly calls buildBuiltins so __import__/exec/eval/
  compile are available without requiring `import builtins` first.
- Fixture 346 covers PickleBuffer over bytes/bytearray/memoryview,
  release semantics, isinstance, SyntaxError class on bad source.

Out of scope: actual Python source compilation (gocopy parser
in development); weakref GC tracking (Go runtime has no weak refs;
runtime.AddCleanup-based fix is post-v0.1.0).
@tamnd tamnd merged commit f8a8b51 into main Apr 29, 2026
1 check passed
@tamnd tamnd deleted the feat/v0.0.346-tail-1476 branch April 29, 2026 07:28
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