summaryrefslogtreecommitdiffstats
path: root/Modules/cPickle.c
Commit message (Collapse)AuthorAgeFilesLines
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-4/+8
| | | | | | | | | | | | | | | | | | | | | | | * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
* Prevent memory leak on error.Neal Norwitz2006-08-021-1/+1
| | | | Reported by Klocwork #36
* Fix memory leaks spotted by Klocwork #37.Neal Norwitz2006-07-231-2/+2
|
* Fix more memory allocation issues found with failmalloc.Neal Norwitz2006-07-221-4/+9
|
* Fix bug #1512695: cPickle.loads could crash if it was interrupted withNeal Norwitz2006-06-281-2/+6
| | | | | | a KeyboardInterrupt since PyTuple_Pack was passed a NULL. Will backport.
* Make use of METH_O and METH_NOARGS where possible.Georg Brandl2006-05-291-22/+9
| | | | Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
* Conversion of exceptions over from faked-up classes to new-style C types.Richard Jones2006-05-271-2/+0
|
* Replace PyObject_CallFunction calls with only object argsGeorg Brandl2006-05-251-2/+2
| | | | with PyObject_CallFunctionObjArgs, which is 30% faster.
* Bug #1473625: stop cPickle making float dumps locale dependent in protocol 0.Georg Brandl2006-04-301-1/+3
| | | | | On the way, add a decorator to test_support to facilitate running single test functions in different locales with automatic cleanup.
* Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters2006-04-151-34/+17
| | | | | | | | using a custom, nearly-identical macro. This probably changes how some of these functions are compiled, which may result in fractionally slower (or faster) execution. Considering the nature of traversal, visiting much of the address space in unpredictable patterns, I'd argue the code readability and maintainability is well worth it ;P
* Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, forThomas Wouters2006-04-151-21/+17
| | | | tp_clear methods.
* Fix some warnings on HP-UX when using cc/aCCNeal Norwitz2006-04-101-2/+1
|
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-3/+3
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-26/+36
|
* Check return result from Py_InitModule*(). This API can fail.Neal Norwitz2006-01-191-0/+2
| | | | Probably should be backported.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-10/+10
| | | | | | | | | | | | | | | | | | | In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
* Eliminate the deprecated option to return None instead of a tuple of ↵Raymond Hettinger2004-12-071-11/+6
| | | | arguments in __reduce__().
* Patch #995766: Keyword argument support in cPickle.Martin v. Löwis2004-07-271-15/+21
|
* Patch #774665: Make Python LC_NUMERIC agnostic.Martin v. Löwis2004-06-081-1/+1
|
* made cPickle fall back to the copy_reg/reduce protocol,Christian Tismer2004-02-261-0/+5
| | | | | if a function cannot be stored as global. This is for compatibility with pickle.py .
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-1/+1
| | | | | | * Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
* The Unpickler forget about its find_class attribute.Jeremy Hylton2003-07-111-0/+3
|
* Remove many blanket try/except clauses.Jeremy Hylton2003-06-161-11/+40
| | | | | | | | | | | | SF bug [ 751276 ] cPickle doesn't raise error, pickle does (recursiondepth) Most of the calls to PyErr_Clear() were intended to catch & clear an attribute error and try something different. Guard all those cases with a PyErr_ExceptionMatches() and fail if some other error occurred. The other error is likely a bug in the user code. This is basically the C equivalent of changing "except:" to "except AttributeError:"
* PyType_Ready(): Complain if the type is a base type, and gc'able, andTim Peters2003-05-211-2/+7
| | | | | | | | | | | | | | | | | | tp_free is NULL or PyObject_Del at the end. Because it's a base type it must call tp_free in its dealloc function, and because it's gc'able it must not call PyObject_Del. inherit_slots(): Don't inherit tp_free unless the type and its base agree about whether they're gc'able. If the type is gc'able and the base is not, and the base uses the default PyObject_Del for its tp_free, give the type PyObject_GC_Del for its tp_free (the appropriate default for a gc'able type). cPickle.c: The Pickler and Unpickler types claim to be base classes and gc'able, but their dealloc functions didn't call tp_free. Repaired that. Also call PyType_Ready() on these typeobjects, so that the correct (PyObject_GC_Del) default memory-freeing function gets plugged into these types' tp_free slots.
* Make Unpickler objects colletable.Jeremy Hylton2003-04-091-23/+65
| | | | Bugfix candidate.
* Make Picklers collectable.Jeremy Hylton2003-04-091-5/+45
| | | | Bug fix candidate.
* New private API functions _PyFloat_{Pack,Unpack}(4,8}. This is aTim Peters2003-03-201-154/+9
| | | | | refactoring to get all the duplicates of this delicate code out of the cPickle and struct modules.
* SF bug 705836: struct.pack of floats in non-native endian orderTim Peters2003-03-201-6/+24
| | | | | | | | | | | | | | pack_float, pack_double, save_float: All the routines for creating IEEE-format packed representations of floats and doubles simply ignored that rounding can (in rare cases) propagate out of a long string of 1 bits. At worst, the end-off carry can (by mistake) interfere with the exponent value, and then unpacking yields a result wrong by a factor of 2. In less severe cases, it can end up losing more low-order bits than intended, or fail to catch overflow *caused* by rounding. Bugfix candidate, but I already backported this to 2.2. In 2.3, this code remains in severe need of refactoring.
* Use __reduce_ex__.Guido van Rossum2003-02-191-45/+36
|
* save_global(): Trying to resolve module.name can fail for twoTim Peters2003-02-181-3/+5
| | | | | | | reasons: importing module can fail, or the attribute lookup module.name can fail. We were giving the same error msg for both cases, making it needlessly hard to guess what went wrong. These cases give different error msgs now.
* Make 2 module variables static. Assuming this is correct.Neal Norwitz2003-02-151-2/+2
|
* cPickle.c, load_build(): Taught cPickle how to pick apartTim Peters2003-02-151-21/+71
| | | | | | | | | | | | | | | | | | the optional proto 2 slot state. pickle.py, load_build(): CAUTION: Noted that cPickle's load_build and pickle's load_build really don't do the same things with the state, and didn't before this patch either. cPickle never tries to do .update(), and has no backoff if instance.__dict__ can't be retrieved. There are no tests that can tell the difference, and part of what cPickle's load_build() did looked accidental to me, so I don't know what the true intent is here. pickletester.py, test_pickle.py: Got rid of the hack for exempting cPickle from running some of the proto 2 tests. dictobject.c, PyDict_Next(): documented intended use.
* cPickle produces NEWOBJ appropriately now. It still doesn't knowTim Peters2003-02-141-69/+195
| | | | how to unpickle the new slot-full state tuples.
* Minor assorted cleanups; no semantic changes.Tim Peters2003-02-131-10/+16
|
* The version of PyImport_Import() in cPickle is no longer needed (an editedTim Peters2003-02-131-64/+0
| | | | version was moved into import.c long ago), so squashed the duplication.
* save(): Reformat tail end just for clarity.Tim Peters2003-02-131-16/+17
|
* Taught cPickle how to read pickles containing NEWOBJ. This won't getTim Peters2003-02-131-1/+75
| | | | | | exercised by the test suite before cPickle knows how to create NEWOBJ too. For now, it was just tried once by hand (via loading a NEWOBJ pickle created by pickle.py).
* Added a HIGHEST_PROTOCOL module attribute to pickle and cPickle.Tim Peters2003-02-131-5/+9
|
* Minor cleanup of new batch-list/dict code.Tim Peters2003-02-121-16/+12
|
* Implemented batching for dicts in cPickle. This is after two failedTim Peters2003-02-111-30/+119
| | | | | attempts to merge the C list-batch and dict-batch code -- they worked, but it was a godawful mess to read.
* Implemented list batching in cPickle.Tim Peters2003-02-111-30/+103
|
* More typo repair.Tim Peters2003-02-051-1/+1
|
* Typo repair.Tim Peters2003-02-051-4/+4
|
* cPickle: exempt two_tuple from GC -- it's a speed hack, and doesn'tTim Peters2003-02-041-1/+6
| | | | | | | | | | | | guarantee to keep valid pointers in its slots. tests: Moved ExtensionSaver from test_copy_reg into pickletester, and use it both places. Once extension codes get assigned, it won't be safe to overwrite them willy nilly in test suites, and ExtensionSaver does a thorough job of undoing any possible damage. Beefed up the EXT[124] tests a bit, to check the smallest and largest codes in each opcode's range too.
* cPickle now generates proto 2 EXT[124] when appropriate.Tim Peters2003-02-041-2/+67
| | | | | Moved such EXT tests as currently exist from TempAbstractPickleTests to AbstractPickleTests, so that test_cpickle runs them too.
* Typo in comment.Tim Peters2003-02-041-1/+1
|
* cPickle can load pickles using proto 2 EXT[124] now, but can't yetTim Peters2003-02-041-0/+108
| | | | generate these opcodes.
* Rename the extension registry variables to have leading underscores --Guido van Rossum2003-02-041-6/+6
| | | | | | | | | this clarifies that they are part of an internal API (albeit shared between pickle.py, copy_reg.py and cPickle.c). I'd like to do the same for copy_reg.dispatch_table, but worry that it might be used by existing code. This risk doesn't exist for the extension registry.
* Typo repair.Tim Peters2003-02-041-1/+1
|
* Brought some module variables into synch with pickle.py's current values.Tim Peters2003-02-041-16/+47
| | | | | Imported the extension-registry dicts from copy_reg.py, in preparation for tackling EXT[124].