-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Pickletools Default Encoding #126997
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard 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
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard 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
Done
Bug report
Bug description:
When unpickling using
_pickle.corpickle.pythroughload/loads, an encoding can be specified using theencodingargument, with the default being ASCII. However, pickletools does not support custom encodings and instead makes assumptions about what encoding it uses, which can lead to either incorrect data being displayed or erroring/not erroring when the normal unpickling process would error.The three opcodes that I have found this in are
STRING,BINSTRING, andSHORT_BINSTRING:STRINGlatin-1forBINSTRINGlatin-1forSHORT_BINSTRINGI think the best solution would be to support encodings as an optional argument in
pickletools.py, with the default being set to ASCII (since that's the default encoding forpickle.pyand_pickle.c).CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs