Skip to content

gh-156942: Raise the exception where the marshalling error is detected - #156944

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:marshal-write-errors
Open

gh-156942: Raise the exception where the marshalling error is detected#156944
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:marshal-write-errors

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

The writer now raises the exception where the error is detected, instead of recording an error code and converting it into an exception at the end. WFILE.error becomes a flag saying that an exception has been raised, w_set_exception() and all error codes except one are removed.

The exception which was already raised is no longer replaced: BufferError for a non-contiguous buffer, TypeError for uncomparable set items, MemoryError for a failed allocation, and the exception raised while marshalling a set item are propagated as they are.

Messages which were ValueError("unmarshallable object") now name the type of the object and, if the type is only supported by newer data formats, the required version.

The error paths were mostly untested, so the tests for them are added, and the existing tests now check the error message.

…etected

Previously the marshal writer recorded an error code and converted it into
an exception at the end, replacing the exception which was already raised
with ValueError("unmarshallable object").  Error messages now name the type
of the unsupported object and the required version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

This started as pure refactoring and error message improvement, but several minor errors was found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant