gh-67766: Improve `struct.pack` out of range error messages by StanFromIreland · Pull Request #132857 · python/cpython · GitHub
Skip to content

gh-67766: Improve struct.pack out of range error messages - #132857

Closed
StanFromIreland wants to merge 5 commits into
python:mainfrom
StanFromIreland:struct-error
Closed

StanFromIreland wants to merge 5 commits into
python:mainfrom
StanFromIreland:struct-error

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Apr 23, 2025

Copy link
Copy Markdown
Member

@StanFromIreland

Copy link
Copy Markdown
Member Author

Comment thread Doc/library/struct.rst Outdated
Comment thread Lib/test/test_struct.py Outdated

@skirpichev skirpichev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I don't like you added argument index to the module state, but alternatives looks more complex.

CC @serhiy-storchaka

@encukou

encukou commented May 5, 2025

Copy link
Copy Markdown
Member

AFAICS, putting the argument index in module state is not thread-safe.

I think the best way to solve this would switching all packing operations to use a new per-operation state struct, which would include a (borrowed) pointer to the module state.

@serhiy-storchaka

Copy link
Copy Markdown
Member

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.

4 participants