gh-128965: pickle load_build
function checks if state
is None, not False
#128966
+1
−1
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.
Inside of the
load_build()
function for pickle'sBUILD
opcode, the C accelerator at one point checks ifstate
isPy_None
, while the Python version only checksif state
.cpython/Modules/_pickle.c
Line 6638 in 34ded1a
cpython/Lib/pickle.py
Line 1765 in 34ded1a
This means if
state
is something like an empty dictionary or tuple, the code block under theif
statement WILL be run in_pickle.c
, but NOT inpickle.py
.As an example, the bytestream
b']]b.'
has the following disassembly:This will do nothing in
pickle.py
but error out in_pickle.c
with the messagestate is not a dictionary
. The easy solution is to changeif state
toif state != None
, and it shouldn't break any existing functionality. I've attached a pull request.load_build
function checks ifstate
is None, not False #128965