-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
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
.
Line 6638 in 34ded1a
if (state != Py_None) { |
Line 1765 in 34ded1a
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:
0: ] EMPTY_LIST
1: ] EMPTY_LIST
2: b BUILD
3: . STOP
highest protocol among opcodes = 1
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.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status