Commit Graph

198 Commits

Author SHA1 Message Date
Alexandre Vassalotti 8b2d713d32 Issue 7128: Removed reference to the non-existent copyreg module.
The reference to copyreg was a unnoticed leftover from the compatibility
support for the grand renaming of the standard library in Python 3. The
compatibility support was reverted in r63493, but not completely as this
patch shows.

Based on a patch by Amaury Forgeot d'Arc.
2009-11-24 17:53:23 +00:00
Eric Smith 97be1ca1d9 Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in cPickle as part of short float repr. 2009-10-27 11:32:11 +00:00
Eric Smith b05d3be2f1 Continue removing _PyOS_double_to_string, as mentioned in issue 7117. 2009-10-26 15:06:39 +00:00
Neil Schemenauer 973f8b4ca6 Make cPickle.Unpickler.noload() handle dict subclasses. noload() is
an obscure, undocumentated feature so no test was added. Closes
issue #1101399.
2009-10-14 19:33:31 +00:00
Amaury Forgeot d'Arc 74b3016783 #6553: crash in cPickle.load(), when given a StringIO with incomplete data.
Will backport to 2.6, 3.x already fixed a similar issue with issue4298.
2009-07-23 19:26:02 +00:00
Collin Winter 57bef68bc0 Issue 5794: fix cPickle's unpickling of recursive tuples. 2009-05-26 04:12:39 +00:00
Collin Winter 179bf213ea Issue 5670: special-case pickling of dicts. This nearly doubles the performance of dict pickling in cPickle. 2009-05-25 04:34:39 +00:00
Antoine Pitrou 7430989cda Isue #5084: unpickling now interns the attribute names of pickled objects,
saving memory and avoiding growth in size of subsequent pickles. Proposal
and original patch by Jake McGuire.
2009-05-02 21:13:23 +00:00
Eric Smith 068f06568b Issue #5835, deprecate PyOS_ascii_formatd.
If anyone wants to clean up the documentation, feel free. It's my first documentation foray, and it's not that great.

Will port to py3k with a different strategy.
2009-04-25 21:40:15 +00:00
Mark Dickinson a3ecd2c668 Issue #1672332: Fix unpickling of subnormal floats, which was raising
ValueError on some platforms as a result of the platform strtod setting
errno on underflow.
2009-01-24 16:40:29 +00:00
Martin v. Löwis 9ac4927125 Issue #4051: Prevent conflict of UNICODE macros in cPickle. 2009-01-02 20:40:14 +00:00
Alexandre Vassalotti f852bf97ef Fix issue #4730: cPickle corrupts high-unicode strings.
Update outdated copy of PyUnicode_EncodeRawUnicodeEscape.
Add a test case.
2008-12-27 07:08:47 +00:00
Amaury Forgeot d'Arc 69a9c5b539 Issue #4176: Pickle would crash the interpreter when a __reduce__ function
does not return an iterator for the 4th and 5th items.
(sequence-like and mapping-like state)

A list is not an iterator...

Will backport to 2.6 and 2.5.
2008-10-30 21:18:34 +00:00
Amaury Forgeot d'Arc 24cb382455 #3640: Correct a crash in cPickle on 64bit platforms, in the case of deeply nested lists or dicts.
Reviewed by Martin von Loewis.
2008-09-11 20:56:13 +00:00
Facundo Batista 763d309bba Fix #2702, with a correct accounting of recursion. 2008-06-30 01:10:55 +00:00
Facundo Batista 68dc052ca6 Reverting the patch from #3165, as it broke other
behaviours. I left the original test commented out (note
that that test came from #2702, which seems to have a
problem in FreeBSD and Windows, but not in Linux).

I included a new test, to watch over the now-broken
behaviour, I took it from #3179.
2008-06-25 19:24:53 +00:00
Thomas Heller b436a24eed Fix compilation on Windows. 2008-06-23 14:49:56 +00:00
Facundo Batista 9da18b3133 Fixing the problem stated in issue 2702 with the patch submitted
in the issue 3165. Now cPickle does not fails with uncontrolled
behaviour when pickling into a very deep nested structure.
2008-06-22 23:19:14 +00:00
Facundo Batista 1461886eee Issue 3164. Small fix to don't repeat a comparation
without necessity.
2008-06-22 15:27:10 +00:00
Gregory P. Smith 9d53457e59 Merge in release25-maint r60793:
Added checks for integer overflows, contributed by Google. Some are
 only available if asserts are left in the code, in cases where they
 can't be triggered from Python code.
2008-06-11 07:41:16 +00:00
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html

Python 2.6 should stick with PyString_* in its codebase.  The PyBytes_* names
in the spirit of 3.0 are available via a #define only.  See the email thread.
2008-06-09 04:58:54 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Georg Brandl dffbf5f542 Revert copy_reg -> copyreg rename. 2008-05-20 07:49:57 +00:00
Alexandre Vassalotti 3c4971c40e Added Python 3.0 warning to cPickle. 2008-05-16 19:14:31 +00:00
Alexandre Vassalotti 9510e4a9f8 Added module stub for copy_reg renaming in 3.0.
Renamed copy_reg to copyreg in the standard library, to avoid
spurious warnings and ease later merging to py3k branch. Public
documentation remains intact.
2008-05-11 08:25:28 +00:00
Gregory P. Smith c20adf8ef2 Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library.  These modules use PyFile_AsFile and later
release the GIL while operating on the previously returned FILE*.
2008-04-07 06:33:21 +00:00
Christian Heimes e93237dfcc #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available. 2007-12-19 02:37:44 +00:00
Neal Norwitz 5a29dd30e0 Fix Coverity #159.
This code was broken if save() returned a negative number since i contained
a boolean value and then we compared i < 0 which should never be true.

Will backport (assuming it's necessary)
2007-10-05 05:01:38 +00:00
Martin v. Löwis 6819210b9e PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Kristján Valur Jónsson 17b8e97e2e Merge change 54909 from release25-maint: Fix several minor issues discovered using code analysis in VisualStudio 2005 Team Edition 2007-04-25 00:10:50 +00:00
Armin Rigo 7ccbca93a2 Forward-port of r52136,52138: a review of overflow-detecting code.
* 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...
2006-10-04 12:17:45 +00:00
Neal Norwitz 99dfe3c411 Prevent memory leak on error.
Reported by Klocwork #36
2006-08-02 04:27:11 +00:00
Neal Norwitz 98a96004f9 Fix memory leaks spotted by Klocwork #37. 2006-07-23 07:57:11 +00:00
Neal Norwitz b59d08c2fb Fix more memory allocation issues found with failmalloc. 2006-07-22 16:20:49 +00:00
Neal Norwitz 0f8b31a2da Fix bug #1512695: cPickle.loads could crash if it was interrupted with
a KeyboardInterrupt since PyTuple_Pack was passed a NULL.

Will backport.
2006-06-28 06:28:31 +00:00
Georg Brandl 96a8c3954c Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
2006-05-29 21:04:52 +00:00
Richard Jones 7b9558d37d Conversion of exceptions over from faked-up classes to new-style C types. 2006-05-27 12:29:24 +00:00
Georg Brandl 684fd0c8ec Replace PyObject_CallFunction calls with only object args
with PyObject_CallFunctionObjArgs, which is 30% faster.
2006-05-25 19:15:31 +00:00
Georg Brandl de9b624fb9 Bug #1473625: stop cPickle making float dumps locale dependent in protocol 0.
On the way, add a decorator to test_support to facilitate running single
test functions in different locales with automatic cleanup.
2006-04-30 11:13:56 +00:00
Thomas Wouters c6e55068ca Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
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
2006-04-15 21:47:09 +00:00
Thomas Wouters edf17d8798 Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
2006-04-15 17:28:34 +00:00
Neal Norwitz b183a25c29 Fix some warnings on HP-UX when using cc/aCC 2006-04-10 01:03:32 +00:00
Martin v. Löwis 15e62742fa Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
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 *.
2005-12-10 18:50:16 +00:00
Raymond Hettinger a6b45cc31d Eliminate the deprecated option to return None instead of a tuple of arguments in __reduce__(). 2004-12-07 07:05:57 +00:00
Martin v. Löwis 544f1195b1 Patch #995766: Keyword argument support in cPickle. 2004-07-27 05:22:33 +00:00
Martin v. Löwis 737ea82a5a Patch #774665: Make Python LC_NUMERIC agnostic. 2004-06-08 18:52:54 +00:00
Christian Tismer 2460c62152 made cPickle fall back to the copy_reg/reduce protocol,
if a function cannot be stored as global.
This is for compatibility with pickle.py .
2004-02-26 16:21:45 +00:00