Commit Graph

114 Commits

Author SHA1 Message Date
Andrew M. Kuchling 6c02916dfb #1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
2008-05-11 13:33:56 +00:00
Neal Norwitz fb43d1e4aa Fix refleak 2008-02-01 07:22:59 +00:00
Christian Heimes 67ac0667f0 Removed unused var 2008-01-30 11:46:00 +00:00
Raymond Hettinger bf3d1d5dc8 Removed unnecessary conditional (spotted by Neal Norwitz). 2008-01-28 21:51:25 +00:00
Raymond Hettinger 52716c94be Let marshal built-up sets and frozensets one element at a time (without creating an intermediate tuple). 2008-01-28 21:34:30 +00:00
Raymond Hettinger dee3f65d98 Revert PySet_Add() changes. 2008-01-26 09:31:11 +00:00
Raymond Hettinger b423f02aa5 Let marshal build-up sets and frozensets one element at a time.
Saves the unnecessary creation of a tuple as intermediate container.
2008-01-26 08:37:28 +00:00
Raymond Hettinger 12e94200c0 Fix marshal's incorrect handling of subclasses of builtin types (backport candidate). 2007-11-07 01:13:09 +00:00
Neal Norwitz 15f2661758 Fix Coverity 185-186: If the passed in FILE is NULL, uninitialized memory
would be accessed.

Will backport.
2007-10-12 03:05:19 +00:00
Neal Norwitz f6b0e4dca8 Last try for tweaking the max stack depth. 5000 was the original value,
4000 didn't work either.  1000 does work on Windows.  If 2000 works,
that will hopefully be a reasonable balance.
2007-05-17 07:04:46 +00:00
Neal Norwitz 4f82bc3183 Set the depth to something very small to try to determine if the
crashes on Windows are really due to the stack size or possibly
some other problem.
2007-05-17 06:23:50 +00:00
Neal Norwitz 117ef0863b Reduce the max stack depth to see if this fixes the segfaults on
Windows and some other boxes.  If this is successful, this rev should
be backported.  I'm not sure how close to the limit we should push this.
2007-05-17 06:11:36 +00:00
Neal Norwitz b1a9b37aa8 Fix bug in marshal where bad data would cause a segfault due to
lack of an infinite recursion check.

Contributed by Damien Miller at Google.
2007-05-16 20:05:11 +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 edb2168079 This code is actually not used unless WITHOUT_COMPLEX is defined.
However, there was no error checking that PyFloat_FromDouble returned
a valid pointer.  I believe this change is correct as it seemed
to follow other code in the area.

Klocwork # 292.
2006-08-12 01:47:59 +00:00
Georg Brandl bf92f46572 Convert more modules to METH_VARARGS. 2006-05-29 21:58:42 +00:00
Martin v. Löwis 725507b52e Change int to Py_ssize_t in several places.
Add (int) casts to silence compiler warnings.
Raise Python exceptions for overflows.
2006-03-07 12:08:51 +00:00
Thomas Wouters 695934a0ef Make Py_ssize_t clean. 2006-03-01 23:49:13 +00:00
Thomas Wouters 7464b43e41 Fix incompatible assignment warning from previous checkin. 2006-03-01 22:34:09 +00:00
Thomas Wouters 7f401ef73d Fix gcc (4.0.x) warning about use of uninitialized variables.
(PyMarshal_ReadShortFromFile() is only used in zipimport.c, I don't believe
the extra initializations will matter one way or another.)
2006-03-01 22:30:47 +00:00
Martin v. Löwis 67baee6287 Move cast to suppress warning. 2006-02-16 14:37:48 +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
Neal Norwitz ef78529e86 version was not initialized properly 2005-11-16 05:04:51 +00:00
Jeremy Hylton ec97a28b60 Fix a bunch of imports to use code.h instead of compile.h.
Remove duplicate declarations from compile.h
2005-10-21 14:58:06 +00:00
Jeremy Hylton 3e0055f8c6 Merge ast-branch to head
This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.

The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
2005-10-20 19:59:25 +00:00
Raymond Hettinger beb3101b05 Add a C API for sets and frozensets. 2005-08-16 03:47:52 +00:00
Brett Cannon c9371d4a1b Fix signedness of various char variables to stop causing a warning under gcc 4. 2005-06-25 08:23:41 +00:00
Michael W. Hudson f2ca5af439 Fix bug
[ 1180997 ] lax error-checking in new-in-2.4 marshal stuff

which I'd assigned to Martin, but actually turned out to be easy to fix.

Also, a test.
2005-06-13 18:28:46 +00:00
Michael W. Hudson 01fca11080 Remove extraneous format character from PyArg_ParseTuple call in
marshal_loads.

Bugfix candidate.
2005-06-13 17:50:18 +00:00
Michael W. Hudson 6d6917be00 Fix a couple of crashing-on-malformed data marshal bugs. 2005-06-03 15:17:16 +00:00
Michael W. Hudson df88846ebc This is my patch:
[ 1180995 ] binary formats for marshalling floats

Adds 2 new type codes for marshal (binary floats and binary complexes), a
new marshal version (2), updates MAGIC and fiddles the de-serializing of
code objects to be less likely to clobber the real reason for failing if
it fails.
2005-06-03 14:41:55 +00:00
Fred Drake d7c27bef52 remove unused variable 2005-01-12 16:00:55 +00:00
Raymond Hettinger a422c34b70 SF 1098985: set objects cannot be marshalled 2005-01-11 03:03:27 +00:00
Armin Rigo 2ccea17856 Any call to marshal.dumps() with the new optional argument 'version' just
immediately segfaults, due to a typo!  This was obviously never tested...
Added a test for it, and also fixed the documentation.
2004-12-20 12:25:57 +00:00
Martin v. Löwis ef82d2fdfe Patch #923098: Share interned strings in marshal. 2004-06-27 16:51:46 +00:00
Neal Norwitz d85c452604 Make private function static 2004-06-13 20:31:49 +00:00
Martin v. Löwis 737ea82a5a Patch #774665: Make Python LC_NUMERIC agnostic. 2004-06-08 18:52:54 +00:00
Armin Rigo 01ab279056 Marshal clean-up (SF patch #873224) 2004-03-26 15:09:27 +00:00
Jason Tishler 6bc06eca70 Bug #794140: cygwin builds do not embed
The embed2.diff patch solves the user's problem by exporting the missing
symbols from the Python core so Python can be embedded in another Cygwin
application (well, at lest vim).
2003-09-04 11:59:50 +00:00
Thomas Heller 37d5a15e02 Whitespace normalization. 2002-07-30 11:44:44 +00:00
Thomas Heller 3e1c18ad0c Fix SF 588452: debug build crashes on marshal.dumps([128] * 1000).
See there for a description.

Added test case.

Bugfix candidate for 2.2.x, not sure about previous versions:
probably low priority, because virtually no one runs debug builds.
2002-07-30 11:40:57 +00:00
Neal Norwitz 7fdcb41131 Fix SF bug # 561858 Assertion with very long lists
Write 4 bytes for co_stacksize, etc. to prevent writing out
bad .pyc files which can cause a crash when read back in.
2002-06-14 01:07:39 +00:00
Guido van Rossum 77f6a65eb0 Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
2002-04-03 22:41:51 +00:00
Neal Norwitz 031829d3ef Use symbolic METH_VARARGS instead of 1 for ml_flags 2002-03-31 14:37:44 +00:00
Jeremy Hylton 9f64caaf00 Use PyObject_CheckReadBuffer(). 2001-11-09 22:02:48 +00:00
Guido van Rossum b8cf3e64be SF patch #470393 (Jim Ahlstrom): Add missing marshal function
In Include/, marshal.h declares both
    PyMarshal_ReadLongFromFile()
    and PyMarshal_ReadShortFromFile(),
    but the second is missing from marshal.c.

[Shouldn't the return type be declared as 'short' instead of 'int'?
But 'int' is what was in marshal.h all those years...  --Guido]
2001-10-19 01:46:21 +00:00
Michael W. Hudson 8019913e4a fix for part of bug #453523: disable unmarshalling of code objects in
restricted execution mode.
2001-08-30 14:50:20 +00:00
Tim Peters 8211237db8 marshal.c r_long64: When reading a TYPE_INT64 value on a box with 32-bit
ints, convert to PyLong (rather than throwing away the high-order 32 bits).
2001-08-29 02:28:42 +00:00
Martin v. Löwis 339d0f720e Patch #445762: Support --disable-unicode
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
2001-08-17 18:39:25 +00:00