v0.0.346: pickle.PickleBuffer + compile/exec/eval SyntaxError (v0.1.0 tail)#267
Merged
Conversation
… 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 atnotes/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.PickleBufferclass with__init__(bytes-like)/__bytes__/raw()/release(). Released ops raiseValueError("operation forbidden on released PickleBuffer object")matching CPython.bytes()builtin honors__bytes__dunder before falling through to the iterable path — required forbytes(PickleBuffer(...))and any user class that defines__bytes__.compile()/exec(str)/eval(str)raiseSyntaxError(previouslyNotImplementedError) with a clear message that goipy is .pyc-only. User code that catchesSyntaxError(the documented compile-time class) now sees the right exception.Interp.New()eagerly callsbuildBuiltins()so__import__/exec/eval/compileare available at the global namespace without needingimport builtinsfirst.Out of scope
gocopyparser is in development; wiring is a separate cycle.weakrefGC 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.dumps/loads— type exposed but wire-format paths unchanged.Test plan
go test ./... -timeout 600s— green