src/msgspec/_core.c: Fix backing type declaration of Ext.code - #1135
Merged
Merged
Conversation
Fixes the TestExt test suite on big-endian systems. `(Ext).code` is implemented by a `long` in the C code, but declared to be backed by an `int` for access from Python. Correct this. When `long` is larger than `int`, the previous declaration caused only an endian-specific part of the `code` value to get returned when read from Python-land. On little-endian it was the lower half, and with the valid range of `code` values being small enough to fit in 1 byte, everything seemed fine. On big-endian, this returned the upper half of the `long` instead, so all `assert`s of `(Ext).code` values failed because the only possible values were 0 and -1.
14 tasks
Merging this PR will improve performance by ×12
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
sobolevn
had a problem deploying
to
docs-preview
August 11, 2026 10:47 — with
GitHub Actions
Failure
sobolevn
approved these changes
Aug 11, 2026
sobolevn
left a comment
Member
There was a problem hiding this comment.
Thank you!
It will make into the 0.22.0 release.
Brohammad
pushed a commit
to Brohammad/msgspec
that referenced
this pull request
Sep 4, 2026
The 0.21.1 to 0.22.0 changelog batch (msgspec#1112) landed on 2026-07-03. Four user-visible changes merged between then and the 0.22.0 release on 2026-08-11 never got an entry: - msgspec#700, overloads on the `Meta` stub, so type checkers reject mixing `gt` with `ge` and `lt` with `le` - msgspec#1028, `null` placed last in the `anyOf` generated for optional unions - msgspec#1114, `__struct_encode_fields__` added to `src/msgspec/__init__.pyi` (its companion msgspec#813 only touched `tests/typing`, so it needs no entry of its own) - msgspec#1118, `json.encode` raising `TypeError` for a `dict` keyed by a plain `str`-valued `enum.Enum` I went over every PR merged in that window. The rest need no entry: msgspec#813 and msgspec#1117 are tests only, msgspec#1121 fixes an unreleased regression from msgspec#1028, msgspec#1145 is an unused variable under free-threaded builds, and msgspec#1146 and msgspec#1148 are CI and tooling. msgspec#1127, msgspec#1135 and msgspec#1080 already have entries. Docs build clean with `--fail-on-warning`. Note for whoever retries the release: the section is still headed `Version 0.22.0 (2026-08-11)`, and that date will need updating, since the tag was deleted after the upload failed. Refs msgspec#1134. Co-authored-by: Siyet <Siyet@users.noreply.github.com>
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.
Fixes the TestExt test suite on big-endian systems.
(Ext).codeis implemented by alongin the C code, but declared to be backed by anintfor access from Python. Correct this.When
longis larger thanint, the previous declaration caused only an endian-specific part of thecodevalue to get returned when read from Python-land. On little-endian it was the lower half, and with the valid range ofcodevalues being small enough to fit in 1 byte, everything seemed fine.On big-endian, this returned the upper half of the
longinstead, so allasserts of(Ext).codevalues failed because the only possible values were 0 and -1.Example output of the tests on a big-endian machine (powerpc64-linux) before this change: