Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-132983: Convert dict_content to take Py_buffer#133924
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
It would probably be good to run the refleaks buildbots on this PR before merge. |
@AA-Turner would you like to pick this up again? I'm happy to take this over if you don't have time. Want to get the last of the zstd items done before b2. |
bedevere-bot commentedMay 24, 2025
🤖 New build scheduled with the buildbot fleet by@AA-Turner for commitfe3fb49 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133924%2Fmerge If you want to schedule another build, you need to add the🔨 test-with-refleak-buildbots label again. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Merged main because there were nonsense errors in the tests. |
90cef43
to30ac9d5
Comparebedevere-bot commentedMay 26, 2025
🤖 New build scheduled with the buildbot fleet by@AA-Turner for commit30ac9d5 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133924%2Fmerge If you want to schedule another build, you need to add the🔨 test-with-refleak-buildbots label again. |
Apologies for the force-push, my local git state got messy. |
Modules/_zstd/zstddict.c Outdated
"Zstandard dictionary content must be longer " | ||
"than eight bytes."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It can also be exactly 8 bytes, right?
What happens if you remove this check? What error will you get?
AA-TurnerMay 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Wording error, sorry.
What happens if you remove this check? What error will you get?
FromRFC 8878 s.5, a dictionary can either be in Zstandard format or 'raw content' format.
"raw content" dictionaries ... must be at least 8 bytes.
- The Zstandard format has a required 4 byte magic number and 4 byte ID
This check only bites whenis_raw
isTrue
, as normally we check that the dict is a valid Zstandard directory viaZSTD_getDictID_fromDict() != 0
. That function returns 0 ifdictSize < 8
or otherwise if the data does not match the Zstandard header.
TheZstandard documentation is quite sparse on 'raw content' dictionaries, but I would conclude that the early error here probably doesn't hurt, and helps ensure we are conformant to the RFC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There is no principal difference between keeping binary data as a bytes object or a raw memory buffer. But if the latter looks better to you, LGTM.
Uh oh!
There was an error while loading.Please reload this page.
f2ce4bb
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…()`` (pythonGH-133924)(cherry picked from commitf2ce4bb)Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
GH-134723 is a backport of this pull request to the3.14 branch. |
Uh oh!
There was an error while loading.Please reload this page.
ZstdDict
'sdict_content
is just binary data, we don't need to allocate an entire PyBytesObject for it. This also lets us use thePy_buffer
argument clinic converter.We replace the
dict_content
member ofZstdDict
withdict_buffer
anddict_len
.ZstdDict.dict_content
is still exposed as a bytes object to Python via a new getter.A
cc@Rogdham