summaryrefslogtreecommitdiff
path: root/Modules/_pickle.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-39573: Use Py_SET_SIZE() function (GH-18402)Victor Stinner2020-02-071-11/+13
| | | | Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function.
* bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)Victor Stinner2020-02-071-1/+1
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39492: Fix a reference cycle between reducer_override and a Pickler ↵Pierre Glaser2020-02-021-4/+18
| | | | | | | | | | | | instance (GH-18266) This also needs a backport to 3.8 https://bugs.python.org/issue39492 Automerge-Triggered-By: @pitrou
* bpo-39426: Fix outdated default and highest protocols in docs (GH-18154)Mark Dickinson2020-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
* bpo-38876: Raise pickle.UnpicklingError when loading an item from memo for ↵Claudiu Popa2019-11-241-4/+8
| | | | | | | | | | | | | | | 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-37206: Unrepresentable default values no longer represented as None. ↵Serhiy Storchaka2019-09-141-16/+16
| | | | | | | (GH-13933) 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.
* bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)Serhiy Storchaka2019-09-011-6/+7
| | | Only AttributeError should be silenced.
* bpo-37502: handle default parameter for buffers argument of pickle.loads ↵Markus Mohrhard2019-07-251-1/+1
| | | | correctly (GH-14593)
* Fix typos in docs, comments and test assert messages (#14872)Min ho Kim2019-07-211-1/+1
|
* bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)Jeroen Demeyer2019-07-111-1/+1
|
* bpo-37337: Add _PyObject_CallMethodNoArgs() (GH-14267)Jeroen Demeyer2019-07-081-1/+1
|
* bpo-37483: add _PyObject_CallOneArg() function (#14558)Jeroen Demeyer2019-07-041-7/+5
|
* bpo-37194: Add a new public PyObject_CallNoArgs() function (GH-13890)Victor Stinner2019-06-171-2/+2
| | | | | | | | | | | | | | | Add a new public PyObject_CallNoArgs() function to the C API: call a callable Python object without any arguments. It is the most efficient way to call a callback without any argument. On x86-64, for example, PyObject_CallFunctionObjArgs(func, NULL) allocates 960 bytes on the stack per call, whereas PyObject_CallNoArgs(func) only allocates 624 bytes per call. It is excluded from stable ABI 3.8. Replace private _PyObject_CallNoArg() with public PyObject_CallNoArgs() in C extensions: _asyncio, _datetime, _elementtree, _pickle, _tkinter and readline.
* 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-301-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-201-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-031-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-031-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-131-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-141-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-131-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.