summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-41288: Fix a crash in unpickling invalid NEWOBJ_EX. (GH-21458)Miss Islington (bot)2020-07-131-8/+21
| | | | | | Automerge-Triggered-By: @tiran (cherry picked from commit 4f309abf55f0e6f8950ac13d6ec83c22b8d47bf8) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-39378: partial of PickleState struct should be traversed. (GH-18046)Miss Islington (bot)2020-03-021-0/+1
| | | | | (cherry picked from commit 1f577ce363121d590b51abf5c41d1bcf3d751436) Co-authored-by: Hai Shi <shihai1992@gmail.com>
* bpo-39681: Fix C pickle regression with minimal file-like objects (GH-18592) ↵Miss Islington (bot)2020-02-231-5/+36
| | | | | | | | | | | | (#18630) Fix a regression where the C pickle module wouldn't allow unpickling from a file-like object that doesn't expose a readinto() method. (cherry picked from commit 9f37872e307734666a7169f7be6e3370d3068282) Co-authored-by: Antoine Pitrou <antoine@python.org> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* [3.8] bpo-39492: Fix a reference cycle between reducer_override and a ↵Antoine Pitrou2020-02-021-4/+18
| | | | | | | | | | | Pickler instance (GH-18266) (#18316) https://bugs.python.org/issue39492 Automerge-Triggered-By: @pitrou (cherry picked from commit 0f2f35e) Co-authored-by: Pierre Glaser <pierreglaser@msn.com>
* bpo-39426: Fix outdated default and highest protocols in docs (GH-18154)Miss Islington (bot)2020-01-241-9/+10
| | | | | | | | 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 (cherry picked from commit e9652e8d58392f5022759ba06b444ce970eb12db) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* [3.8] bpo-37206: Unrepresentable default values no longer represented as ↵Serhiy Storchaka2019-09-141-16/+16
| | | | | | | | | | None. (GH-13933) (GH-16141) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all. (cherry picked from commit 279f44678c8b84a183f9eeb85e0b086228154497) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.8] bpo-37994: Fix silencing all errors if an attribute lookup fails. ↵Serhiy Storchaka2019-09-011-6/+7
| | | | | | | (GH-15630) (GH-15635) Only AttributeError should be silenced. (cherry picked from commit 41c57b335330ff48af098d47e379e0f9ba09d233)
* bpo-37502: handle default parameter for buffers argument of pickle.loads ↵Miss Islington (bot)2019-07-251-1/+1
| | | | | | | correctly (GH-14593) (cherry picked from commit 898318b53d921298d1f1fcfa0f415844afbeb318) Co-authored-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
* [3.8] Fix typos in docs, comments and test assert messages (GH-14872). (#14900)Kyle Stanley2019-07-221-1/+1
| | | | | (cherry picked from commit 96e12d5f4f3c5a20986566038ee763dff3c228a1) Co-authored-by: Min ho Kim <minho42@gmail.com>
* bpo-31829: Make protocol 0 pickles be loadable in text mode in Python 2. ↵Serhiy Storchaka2019-05-311-1/+4
| | | | | | (GH-11859) Escape ``\r``, ``\0`` and ``\x1a`` (end-of-file on Windows) in Unicode strings.
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-8/+8
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-36785: PEP 574 implementation (GH-7076)Antoine Pitrou2019-05-261-55/+456
|
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-0/+5
| | | 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-2/+42
| | | | 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-8/+40
| | | | | 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-18372: Add missing PyObject_GC_Track() calls in the pickle module (GH-8505)Zackery Spytz2019-04-231-0/+3
|
* bpo-36635: Change pyport.h for Py_BUILD_CORE_MODULE define (GH-12853)Victor Stinner2019-04-171-4/+7
| | | | | | | | | | | | | | | | | | | | Change PyAPI_FUNC(type), PyAPI_DATA(type) and PyMODINIT_FUNC macros of pyport.h when Py_BUILD_CORE_MODULE is defined. The Py_BUILD_CORE_MODULE define must be now be used to build a C extension as a dynamic library accessing Python internals: export the PyInit_xxx() function in DLL exports on Windows. Changes: * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE now imply Py_BUILD_CORE directy in pyport.h. * ceval.c compilation now fails with an error if Py_BUILD_CORE is not defined, just to ensure that Python is build with the correct defines. * setup.py now compiles _pickle.c with Py_BUILD_CORE_MODULE define. * setup.py compiles _json.c with Py_BUILD_CORE_MODULE define, rather than Py_BUILD_CORE_BUILTIN define * PCbuild/pythoncore.vcxproj: Add Py_BUILD_CORE_BUILTIN define.
* bpo-34572: change _pickle unpickling to use import rather than retrieving ↵tjb9002019-02-181-6/+6
| | | | | from sys.modules (GH-9047) Fix C implementation of pickle.loads to use importlib's locking mechanisms, and thereby avoid using partially-loaded modules.
* bpo-35444: Unify and optimize the helper for getting a builtin object. ↵Serhiy Storchaka2018-12-111-6/+2
| | | | | | | | (GH-11047) This speeds up pickling of some iterators. This fixes also error handling in pickling methods when fail to look up builtin "getattr".
* bpo-34987: Fix a possible null pointer dereference in _pickle.c's ↵Zackery Spytz2018-12-051-1/+4
| | | | save_reduce(). (GH-9886)
* bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Serhiy Storchaka2018-11-271-8/+8
| | | Fix also return type for few other functions (clear, releasebuffer).
* bpo-35059: Cleanup usage of Python macros (GH-10648)Victor Stinner2018-11-221-7/+19
| | | | | | | | | | | | | Don't pass complex expressions but regular variables to Python macros. * _datetimemodule.c: split single large "if" into two "if" in date_new(), time_new() and datetime_new(). * _pickle.c, load_extension(): flatten complex "if" expression into more regular C code. * _ssl.c: addbool() now uses a temporary bool_obj to only evaluate the value once. * weakrefobject.c: replace "Py_INCREF(result = proxy);" with "result = proxy; Py_INCREF(result);"
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Serhiy Storchaka2018-11-051-2/+2
| | | | | | | | | | (GH-10284) Two kind of mistakes: 1. Missed space. After concatenating there is no space between words. 2. Missed comma. Causes unintentional concatenating in a list of strings.
* Fix incorrect error handling in _pickle.Unpickler.__init__() (GH-9630)Zackery Spytz2018-09-291-1/+1
| | | | _pickle.Unpickler.__init__() should return -1 if Pdata_New() fails, not 1.
* closes bpo-34656: Avoid relying on signed overflow in _pickle memos. (GH-9261)Benjamin Peterson2018-09-211-31/+31
|
* bpo-34395: Don't free allocated memory on realloc fail in load_mark() in ↵Sergey Fedoseev2018-08-251-15/+5
| | | | _pickle.c. (GH-8788)
* Fix upsizing of marks stack in pickle module. (GH-8860)Sergey Fedoseev2018-08-251-1/+1
| | | Previously marks stack was upsized even there was space for additional item.
* bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)Alexey Izbyshev2018-08-221-0/+2
| | | Reported by Svace static analyzer.
* bpo-34395: Fix memory leaks caused by incautious usage of PyMem_Resize(). ↵Sergey Fedoseev2018-08-161-6/+7
| | | | (GH-8756)
* bpo-34141: Optimized pickling simple non-recursive values. (GH-8318)Serhiy Storchaka2018-07-181-20/+16
|
* bpo-23403: Bump pickle.DEFAULT_PROTOCOL to 4 (#6355)Łukasz Langa2018-04-041-7/+11
| | | 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-33209: End framing at the end of C implementation of ↵Serhiy Storchaka2018-04-031-2/+3
| | | | pickle.Pickler.dump(). (GH-6363)
* bpo-32746: Fix multiple typos (GH-5144)Leo Arias2018-02-041-1/+1
| | | Fix typos found by codespell in docs, docstrings, and comments.
* bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code ↵Serhiy Storchaka2018-01-251-92/+47
| | | | | (GH-5222) Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
* bpo-32503: Avoid creating too small frames in pickles. (#5127)Serhiy Storchaka2018-01-201-9/+9
|
* bpo-31993: Do not use memoryview when pickle large strings. (#5154)Serhiy Storchaka2018-01-121-2/+3
| | | | | | PyMemoryView_FromMemory() created a memoryview referring to the internal data of the string. When the string is destroyed the memoryview become referring to a freed memory.
* bpo-31993: Do not create frames for large bytes and str objects (#5114)Serhiy Storchaka2018-01-111-94/+86
| | | | | | | when serialize into memory buffer with C pickle implementations. This optimization already is performed when serialize into memory with Python pickle implementations or into a file with both implementations.
* bpo-31993: Do not allocate large temporary buffers in pickle dump. (#4353)Olivier Grisel2018-01-061-24/+114
| | | | | | | | | | | | | | | | | 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-28416: Break reference cycles in Pickler and Unpickler subclasses (#4080)Serhiy Storchaka2017-11-301-38/+98
| | | | with the persistent_id() and persistent_load() methods.
* bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. (#4407)Serhiy Storchaka2017-11-161-23/+23
|
* bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() ↵Mat M2017-11-131-1/+5
| | | | (#4384)
* bpo-31572: Get rid of using _PyObject_HasAttrId() in pickle. (#3729)Serhiy Storchaka2017-10-221-30/+33
|
* bpo-28411: Support other mappings in PyInterpreterState.modules. (#3593)Eric Snow2017-09-151-39/+68
| | | | | The concrete PyDict_* API is used to interact with PyInterpreterState.modules in a number of places. This isn't compatible with all dict subclasses, nor with other Mapping implementations. This patch switches the concrete API usage to the corresponding abstract API calls. We also add a PyImport_GetModule() function (and some other helpers) to reduce a bunch of code duplication.
* bpo-31338 (#3374)Barry Warsaw2017-09-151-2/+1
| | | | | | | * Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
* bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#3565)Eric Snow2017-09-141-2/+10
| | | PR #1638, for bpo-28411, causes problems in some (very) edge cases. Until that gets sorted out, we're reverting the merge. PR #3506, a fix on top of #1638, is also getting reverted.
* bpo-30860: Move windows.h include out of internal/*.h. (#3458)Eric Snow2017-09-121-1/+1
| | | PR #3397 introduced a large number of warnings to the Windows build. This patch fixes them.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+7
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* _pickle: Fix whichmodule() (#3358)Victor Stinner2017-09-051-1/+1
| | | | | | _PyUnicode_FromId() can return NULL: replace Py_INCREF() with Py_XINCREF(). Fix coverity report: CID 1417269.
* bpo-28411: Remove "modules" field from Py_InterpreterState. (#1638)Eric Snow2017-09-041-10/+2
| | | sys.modules is the one true source.
* bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. ↵Serhiy Storchaka2017-03-211-9/+9
| | | | (#748)