summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-41288: Fix a crash in unpickling invalid NEWOBJ_EX. (GH-21458) (GH-21461)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>
* [3.7] Fix typos in docs, comments and test assert messages (GH-14872). (#14901)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. ↵Miss Islington (bot)2019-06-121-1/+4
| | | | | | | | (GH-11859) Escape ``\r``, ``\0`` and ``\x1a`` (end-of-file on Windows) in Unicode strings. (cherry picked from commit 38ab7d4721b422547f7b46b9d68968863fa70573) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-18372: Add missing PyObject_GC_Track() calls in the pickle module (GH-8505)Miss Islington (bot)2019-04-231-0/+3
| | | | | (cherry picked from commit 359bd4f61b9e1493081f4f67882554247b53926a) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-34572: change _pickle unpickling to use import rather than retrieving ↵Miss Islington (bot)2019-02-181-6/+6
| | | | | | | | from sys.modules (GH-9047) (GH-11921) Fix C implementation of pickle.loads to use importlib's locking mechanisms, and thereby avoid using partially-loaded modules. (cherry picked from commit 4371c0a9c0848f7a0947d43f26f234842b41efdf) Co-authored-by: tjb900 <ozburgess@gmail.com>
* bpo-35444: Fix error handling when fail to look up builtin "getattr". ↵Serhiy Storchaka2018-12-111-6/+2
| | | | | (GH-11047) (GH-11107) (cherry picked from commit bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d)
* bpo-34987: Fix a possible null pointer dereference in _pickle.c's ↵Miss Islington (bot)2018-12-051-1/+4
| | | | | | | save_reduce(). (GH-9886) (cherry picked from commit 25d389789c59a52a31770f7c50ce9e02a8909190) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Miss Islington (bot)2018-11-271-8/+8
| | | | | | Fix also return type for few other functions (clear, releasebuffer). (cherry picked from commit d4f9cf5545d6d8844e0726552ef2e366f5cc3abd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Miss Islington (bot)2018-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. (cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Fix incorrect error handling in _pickle.Unpickler.__init__() (GH-9630)Miss Islington (bot)2018-09-291-1/+1
| | | | | | _pickle.Unpickler.__init__() should return -1 if Pdata_New() fails, not 1. (cherry picked from commit 4b430e5f6954ef4b248e95bfb4087635dcdefc6d) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* closes bpo-34656: Avoid relying on signed overflow in _pickle memos. (GH-9261)Miss Islington (bot)2018-09-211-31/+31
| | | | | (cherry picked from commit a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)Miss Islington (bot)2018-08-221-0/+2
| | | | | | Reported by Svace static analyzer. (cherry picked from commit f8c06b028036e50596e75d4c9f6b27ba05133efe) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* bpo-34395: Fix memory leaks caused by incautious usage of PyMem_Resize(). ↵Miss Islington (bot)2018-08-161-6/+7
| | | | | | | (GH-8756) (cherry picked from commit 67b9cc8e6072a919d2ed7e7ecc8124c8acfb3733) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
* bpo-33209: End framing at the end of C implementation of ↵Miss Islington (bot)2018-04-031-2/+3
| | | | | | | pickle.Pickler.dump(). (GH-6366) (cherry picked from commit c869529ea9fbed574d34cf7ac139ca3f81b62ef0) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.7] bpo-32746: Fix multiple typos (GH-5144) (GH-5520)Miss Islington (bot)2018-02-041-1/+1
| | | | | | Fix typos found by codespell in docs, docstrings, and comments. (cherry picked from commit c3d9508ff22ece9a96892b628dd5813e2fb0cd80) Co-authored-by: Leo Arias <leo.arias@canonical.com>
* 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)
* Issue #29368: Fix _Pickle_FastCall() usage in do_append()Victor Stinner2017-02-021-1/+0
| | | | | _Pickle_FastCall() has a surprising API: it decrements the reference counter of its second argument.
* Issue #29368: The extend() method is now called instead of the append()Serhiy Storchaka2017-02-021-19/+41
| | | | | method when unpickle collections.deque and other list-like objects. This can speed up unpickling to 2 times.
* Issue #29190: Fixed possible errors in comparing strings in the pickle module.Serhiy Storchaka2017-01-091-12/+6
|\
| * Issue #29190: Fixed possible errors in comparing strings in the pickle module.Serhiy Storchaka2017-01-091-12/+6
| |\
| | * Issue #29190: Fixed possible errors in comparing strings in the pickle module.Serhiy Storchaka2017-01-091-12/+6
| | |
* | | Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka2016-12-161-9/+6
| | | | | | | | | | | | dict.
* | | Initialize variables to fix compiler warningsVictor Stinner2016-12-091-3/+3
| | | | | | | | | | | | | | | Warnings seen on the "AMD64 Debian PGO 3.x" buildbot. Warnings are false positive, but variable initialization should not harm performances.
* | | Use _PyObject_CallMethodIdObjArgs()Victor Stinner2016-12-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() in various modules when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string.
* | | Issue #28858: Remove _PyObject_CallArg1() macroVictor Stinner2016-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue.
* | | Added the const qualifier to char* variables that refer to readonly internalSerhiy Storchaka2016-11-201-2/+2
|/ / | | | | | | UTF-8 represenatation of Unicode objects.
* | Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-1/+1
| | | | | | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
* | Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-1/+1
|\ \ | |/ | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
| * Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-1/+1
| | | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
* | Issue #25761: Improved error reporting about truncated pickle data inSerhiy Storchaka2016-09-061-39/+41
| | | | | | | | | | C implementation of unpickler. UnpicklingError is now raised instead of AttributeError and ValueError in some cases.
* | Avoid inefficient way to call functions without argumentVictor Stinner2016-09-061-1/+1
| | | | | | | | | | | | Don't pass "()" format to PyObject_CallXXX() to call a function without argument: pass NULL as the format string instead. It avoids to have to parse a string to produce 0 argument.
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-2/+2
| |
* | _pickle: remove outdated commentVictor Stinner2016-08-241-11/+0
| | | | | | | | | | | | | | _Pickle_FastCall() is now fast again! The optimization was introduced in Python 3.2, removed in Python 3.4 and reintroduced in Python 3.6 (thanks to the new generic fastcall functions).