Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-45034: Fixes how upper limit is formatted for struct.pack("H", ...) #28178

Merged
merged 6 commits into from
Sep 7, 2021

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Sep 5, 2021

https://bugs.python.org/issue45034

It was:

struct.error: ushort format requires 0 <= number <= (0x7fff * 2 + 1)

It is now:

struct.error: ushort format requires 0 <= number <= 65535

Modules/_struct.c Outdated Show resolved Hide resolved
@mdickinson
Copy link
Member

Thanks for the PR. I think we should extend the fix to np_short, too: those uses of Py_STRINGIFY never really made much sense.

Modules/_struct.c Outdated Show resolved Hide resolved
sobolevn and others added 2 commits September 6, 2021 11:21
Co-authored-by: Mark Dickinson <[email protected]>
Co-authored-by: Mark Dickinson <[email protected]>
@sobolevn
Copy link
Member Author

sobolevn commented Sep 6, 2021

I think we should extend the fix to np_short, too: those uses of Py_STRINGIFY never really made much sense.

Will do! Thanks a lot for your help 👍

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

LGTM; thank you! Do you want to add your name to the list in Misc/ACKS? (It's entirely optional.)

@sobolevn
Copy link
Member Author

sobolevn commented Sep 7, 2021

Do you want to add your name to the list in Misc/ACKS?

Why not? 😄 Added!

Thanks a lot for your help! 👍

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

What about other integer and floating point types?

Modules/_struct.c Outdated Show resolved Hide resolved
@mdickinson
Copy link
Member

What about other integer and floating point types?

I think we can leave broader changes for a separate PR, if anyone feels inclined; this PR addresses the immediate issue that @stevendaprano was seeing, which was due to inappropriate uses of Py_STRINGIFY.

Co-authored-by: Serhiy Storchaka <[email protected]>
@sobolevn
Copy link
Member Author

sobolevn commented Sep 7, 2021

Let's have an explicit cast then 🙂

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.

5 participants