summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] gh-85567: Fix resouce warnings in pickle and pickletools CLIs ↵Miss Islington (bot)2024-01-051-3/+7
| | | | | | | | (GH-113618) (GH-113759) Explicitly open and close files instead of using FileType. (cherry picked from commit bd754b93ca837aa1f239252437a211271d068b71) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] gh-113028: Correctly memoize str in pickle when escapes added ↵Miss Islington (bot)2023-12-241-7/+7
| | | | | | | | | | (GH-113436) (GH-113449) 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. (cherry picked from commit 08398631a0298dcf785ee7bd0e26c7844823ce59) Co-authored-by: Jeff Allen <ja.py@farowl.co.uk>
* gh-90494: Reject 6th element of the __reduce__() tuple (GH-93609) (GH-93631)Miss Islington (bot)2022-06-101-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. (cherry picked from commit a365dd64c2a1f0d142540d5031003f24986f489f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* 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.
| * 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.
* | Issue #23611: Serializing more "lookupable" objects (such as unbound methodsSerhiy Storchaka2015-03-311-15/+18
|/ | | | or nested classes) now are supported with pickle protocols < 4.
* Issue #18473: Fixed 2to3 and 3to2 compatible pickle mappings.Serhiy Storchaka2015-03-311-2/+2
| | | | | | | | Fixed ambigious reverse mappings. Added many new mappings. Import mapping is no longer applied to modules already mapped with full name mapping. Added tests for compatible pickling and unpickling and for consistency of _compat_pickle mappings.
* Issue #23094: Fixed readline with frames in Python implementation of pickle.Serhiy Storchaka2015-01-261-1/+1
|
* Issue #21905: Avoid RuntimeError in pickle.whichmodule() when sys.modules is ↵Antoine Pitrou2014-10-041-1/+3
| | | | | | mutated while iterating. Patch by Olivier Grisel.
* Issue #20976: pyflakes: Remove unused importsVictor Stinner2014-03-201-1/+1
|
* Issue #6784: Strings from Python 2 can now be unpickled as bytes objects.Alexandre Vassalotti2013-12-071-29/+42
| | | | | | | Initial patch by Merlijn van Deen. I've added a few unrelated docstring fixes in the patch while I was at it, which makes the documentation for pickle a bit more consistent.
* Issue #6477: Merge with 3.3.Alexandre Vassalotti2013-12-011-1/+10
|\
| * Issue #6477: Added support for pickling the types of built-in singletons.Alexandre Vassalotti2013-12-011-1/+10
| |
* | Make Ellipsis and NotImplemented picklable through the reduce protocol.Alexandre Vassalotti2013-11-241-8/+0
| |
* | Make built-in methods picklable through the reduce protocol.Alexandre Vassalotti2013-11-241-8/+1
| |
* | Make framing optional in pickle protocol 4.Alexandre Vassalotti2013-11-241-71/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow us to control in the future whether to use framing or not. For example, we may want to turn it off for tiny pickle where it doesn't help. The change also improves performance slightly: ### fastpickle ### Min: 0.608517 -> 0.557358: 1.09x faster Avg: 0.798892 -> 0.694738: 1.15x faster Significant (t=3.45) Stddev: 0.17145 -> 0.12704: 1.3496x smaller Timeline: http://goo.gl/3xQE1J ### pickle_dict ### Min: 0.669920 -> 0.615271: 1.09x faster Avg: 0.733633 -> 0.645058: 1.14x faster Significant (t=5.05) Stddev: 0.12041 -> 0.02961: 4.0662x smaller Timeline: http://goo.gl/LpLSXI ### pickle_list ### Min: 0.397583 -> 0.368112: 1.08x faster Avg: 0.412784 -> 0.397223: 1.04x faster Significant (t=2.78) Stddev: 0.01518 -> 0.03653: 2.4068x larger Timeline: http://goo.gl/v39E59 ### unpickle_list ### Min: 0.692935 -> 0.594870: 1.16x faster Avg: 0.730012 -> 0.628395: 1.16x faster Significant (t=17.76) Stddev: 0.02720 -> 0.02995: 1.1012x larger Timeline: http://goo.gl/2P9AEt The following not significant results are hidden, use -v to show them: fastunpickle.
* | Issue #17810: Implement PEP 3154, pickle protocol 4.Antoine Pitrou2013-11-231-154/+428
| | | | | | | | Most of the work is by Alexandre.
* | Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-2/+2
|\ \ | |/ | | | | error messages and comments.