You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside of the load_build() function for pickle's BUILD opcode, the C accelerator at one point checks if state is Py_None, while the Python version only checks if state.
This means if state is something like an empty dictionary or tuple, the code block under the if statement WILL be run in _pickle.c, but NOT in pickle.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 message state is not a dictionary. The easy solution is to change if state to if state != None, and it shouldn't break any existing functionality. I've attached a pull request.
Bug report
Bug description:
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.CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
load_build
function checks ifstate
is None, not False #128966The text was updated successfully, but these errors were encountered: