summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-126489: Do not call persistent_id() for a persistent id in Python pickle ↵Serhiy Storchaka2024-11-061-4/+5
| | | | (GH-126490)
* gh-126317: Simplify pickle code by using itertools.batched() (GH-126323)Lee Dong Wook2024-11-021-39/+22
|
* gh-122213: Add notes for pickle serialization errors (GH-122214)Serhiy Storchaka2024-09-091-45/+131
| | | | This allows to identify the source of the error.
* gh-122311: Improve and unify pickle errors (GH-122771)Serhiy Storchaka2024-09-091-41/+49
| | | | | | | | | | | | | * Raise PicklingError instead of UnicodeEncodeError, ValueError and AttributeError in both implementations. * Chain the original exception to the pickle-specific one as __context__. * Include the error message of ImportError and some AttributeError in the PicklingError error message. * Unify error messages between Python and C implementations. * Refer to documented __reduce__ and __newobj__ callables instead of internal methods (e.g. save_reduce()) or pickle opcodes (e.g. NEWOBJ). * Include more details in error messages (what expected, what got). * Avoid including a potentially long repr of an arbitrary object in error messages.
* gh-123431: Harmonize extension code checks in pickle (GH-123434)Serhiy Storchaka2024-08-291-7/+11
| | | | | | | | | This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken. * The Python implementation now raises exception for the extension code with false boolean value. * Simplify the C code. RuntimeError is now raised in explicit checks. * Add many tests.
* gh-122459: Optimize pickling by name objects without __module__ (GH-122460)Serhiy Storchaka2024-08-051-49/+48
|
* gh-122311: Fix some error messages in pickle (GH-122386)Serhiy Storchaka2024-07-291-3/+4
|
* gh-122311: Fix typo in the pickle error formatting code (GH-122312)Serhiy Storchaka2024-07-261-1/+1
|
* gh-82951: Fix serializing by name in pickle protocols < 4 (GH-122149)Serhiy Storchaka2024-07-251-9/+31
| | | | | | Serializing objects with complex __qualname__ (such as unbound methods and nested classes) by name no longer involves serializing parent objects by value in pickle protocols < 4.
* gh-118830: Bump pickle.DEFAULT_PROTOCOL to 5 (GH-119340)Rodrigo Oliveira2024-07-191-3/+3
|
* gh-120380: fix Python implementation of `pickle.Pickler` for `bytes` and ↵Bénédikt Tran2024-06-211-15/+35
| | | | `bytearray` objects in protocol version 5. (GH-120422)
* gh-85567: Fix resouce warnings in pickle and pickletools CLIs (GH-113618)Serhiy Storchaka2024-01-051-3/+7
| | | Explicitly open and close files instead of using FileType.
* gh-113028: Correctly memoize str in pickle when escapes added (GH-113436)Jeff Allen2023-12-241-7/+7
| | | | | | This fixes a divergence between the Python and C implementations of pickle for protocol 0, such that it pickle.py fails to re-use the first pickled representation of strings involving characters that have to be escaped.
* gh-93627: Align Python implementation of pickle with C implementation of ↵Pieter Eendebak2023-09-101-10/+12
| | | | | pickle (GH-103035) If a method like __reduce_ex_ or __reduce__ is set to None, a TypeError is raised.
* gh-102799: use exception instance instead of sys.exc_info() (#102885)Irit Katriel2023-03-311-1/+1
|
* gh-99482: remove `jython` compatibility parts from stdlib and tests (#99484)Nikita Sobolev2022-12-231-8/+0
|
* gh-90494: Reject 6th element of the __reduce__() tuple (GH-93609)Serhiy Storchaka2022-06-091-1/+1
| | | | | copy.copy() and copy.deepcopy() now always raise a TypeError if __reduce__() returns a tuple with length 6 instead of silently ignore the 6th item or produce incorrect result.
* Fix typos in the Lib directory (GH-28775)Christian Clauss2021-10-061-1/+1
| | | | | Fix typos in the Lib directory as identified by codespell. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-43907: add missing memoize call in pure python pickling of bytearray ↵Carl Friedrich Bolz-Tereick2021-04-231-0/+1
| | | | (GH-25501)
* bpo-42406: Fix whichmodule() with multiprocessing (GH-23403)Renato Cunha2020-11-291-1/+3
| | | | | | * bpo-42406: Fix whichmodule() with multiprocessing Signed-off-by: Renato L. de F. Cunha <renatoc@br.ibm.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-39435: Make the first argument of pickle.loads() positional-only. (GH-19846)Serhiy Storchaka2020-05-021-2/+2
| | | | It was positional-only de facto: documentation and two implementations used three different name.
* bpo-40327: Improve atomicity, speed, and memory efficiency of the items() ↵Raymond Hettinger2020-04-211-1/+1
| | | | loop (GH-19628)
* bpo-39426: Fix outdated default and highest protocols in docs (GH-18154)Mark Dickinson2020-01-241-3/+3
| | | | | | Some portions of the pickle documentation hadn't been updated for the pickle protocol changes in Python 3.8 (new protocol 5, default protocol 4). This PR fixes those docs. https://bugs.python.org/issue39426
* bpo-38876: Raise pickle.UnpicklingError when loading an item from memo for ↵Claudiu Popa2019-11-241-3/+15
| | | | | | | | | | | | | | | invalid input (GH-17335) The previous code was raising a `KeyError` for both the Python and C implementation. This was caused by the specified index of an invalid input which did not exist in the memo structure, where the pickle stores what objects it has seen. The malformed input would have caused either a `BINGET` or `LONG_BINGET` load from the memo, leading to a `KeyError` as the determined index was bogus. https://bugs.python.org/issue38876 https://bugs.python.org/issue38876
* bpo-37210: Fix pure Python pickle when _pickle is unavailable (GH-14016)Victor Stinner2019-06-131-26/+33
| | | | | | | Allow pure Python implementation of pickle to work even when the C _pickle module is unavailable. Fix test_pickle when _pickle is missing: declare PyPicklerHookTests outside "if has_c_implementation:" block.
* bpo-31829: Make protocol 0 pickles be loadable in text mode in Python 2. ↵Serhiy Storchaka2019-05-311-0/+3
| | | | | | (GH-11859) Escape ``\r``, ``\0`` and ``\x1a`` (end-of-file on Windows) in Unicode strings.
* bpo-36785: PEP 574 implementation (GH-7076)Antoine Pitrou2019-05-261-13/+139
|
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-0/+1
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-35900: Enable custom reduction callback registration in _pickle (GH-12499)Pierre Glaser2019-05-081-20/+28
| | | | Enable custom reduction callback registration for functions and classes in _pickle.c, using the new Pickler's attribute ``reducer_override``.
* bpo-35900: Add a state_setter arg to save_reduce (GH-12588)Pierre Glaser2019-05-081-5/+22
| | | | | Allow reduction methods to return a 6-item tuple where the 6th item specifies a custom state-setting method that's called instead of the regular ``__setstate__`` method.
* bpo-11572: Make minor improvements to copy module (GH-8208)Berker Peksag2018-07-091-5/+1
| | | | | | | * When doing getattr lookups with a default of "None", it now uses an "is" comparison against None which is more correct * Removed outdated code Patch by Brandon Rhodes.
* bpo-23403: Bump pickle.DEFAULT_PROTOCOL to 4 (#6355)Łukasz Langa2018-04-041-5/+5
| | | This makes performance better and produces shorter pickles. This change is backwards compatible up to the oldest currently supported version of Python (3.4).
* bpo-32503: Avoid creating too small frames in pickles. (#5127)Serhiy Storchaka2018-01-201-5/+7
|
* bpo-31993: Do not allocate large temporary buffers in pickle dump. (#4353)Olivier Grisel2018-01-061-10/+40
| | | | | | | | | | | | | | | | | The picklers do no longer allocate temporary memory when dumping large bytes and str objects into a file object. Instead the data is directly streamed into the underlying file object. Previously the C implementation would buffer all content and issue a single call to file.write() at the end of the dump. With protocol 4 this behavior has changed to issue one call to file.write() per frame. The Python pickler with protocol 4 now dumps each frame content as a memoryview to an IOBytes instance that is never reused and the memoryview is no longer released after the call to write. This makes it possible for the file object to delay access to the memoryview of previous frames without forcing any additional memory copy as was already possible with the C pickler.
* bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. (#4407)Serhiy Storchaka2017-11-161-1/+4
|
* bpo-29762: More use "raise from None". (#569)Serhiy Storchaka2017-04-051-3/+3
| | | This hides unwanted implementation details from tracebacks.
* Issue #29368: The extend() method is now called instead of the append()Serhiy Storchaka2017-02-021-5/+12
| | | | | method when unpickle collections.deque and other list-like objects. This can speed up unpickling to 2 times.
* Issue #17711: Fixed unpickling by the persistent ID with protocol 0.Serhiy Storchaka2016-07-171-2/+10
|\ | | | | | | Original patch by Alexandre Vassalotti.
| * Issue #17711: Fixed unpickling by the persistent ID with protocol 0.Serhiy Storchaka2016-07-171-2/+10
| | | | | | | | Original patch by Alexandre Vassalotti.
* | Issue #27076: Merge spelling from 3.5Martin Panter2016-05-261-1/+1
|\ \ | |/
| * Issue #27076: Doc, comment and tests spelling fixesMartin Panter2016-05-261-1/+1
| | | | | | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* | Issue #25761: Improved detecting errors in broken pickle data.Serhiy Storchaka2015-12-061-52/+36
| |
* | Removed debugging output of exception raised by __reduce__ method.Serhiy Storchaka2015-11-301-7/+1
|\ \ | |/
| * Removed debugging output of exception raised by __reduce__ method.Serhiy Storchaka2015-11-301-7/+1
| |\
| | * Removed debugging output of exception raised by __reduce__ method.Serhiy Storchaka2015-11-301-7/+1
| | |
* | | Issue #25523: Merge a-to-an corrections from 3.5Martin Panter2015-11-021-2/+2
|\ \ \ | |/ /
| * | Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5Martin Panter2015-11-021-2/+2
| |\ \ | | |/
| | * Issue #25523: Correct "a" article to "an" articleMartin Panter2015-11-021-2/+2
| | | | | | | | | | | | | | | | | | This changes the main documentation, doc strings, source code comments, and a couple error messages in the test suite. In some cases the word was removed or edited some other way to fix the grammar.
* | | Issue #24164: Objects that need calling ``__new__`` with keyword arguments,Serhiy Storchaka2015-10-101-5/+12
|/ / | | | | | | can now be pickled using pickle protocols older than protocol version 4.
* | Issue #25262. Added support for BINBYTES8 opcode in Python implementation ofSerhiy Storchaka2015-09-291-0/+8
|\ \ | |/ | | | | | | unpickler. Highest 32 bits of 64-bit size for BINUNICODE8 and BINBYTES8 opcodes no longer silently ignored on 32-bit platforms in C implementation.