Commit Graph

2983 Commits

Author SHA1 Message Date
Jason Tishler 8437570ec2 Patch #676837: Cygwin array module patch
The attached patch enables the array module
to build cleanly under Cygwin again.
2003-02-10 20:45:47 +00:00
Neal Norwitz 4adc9abc32 Fix memory leak of newstr when putenv() fails 2003-02-10 03:10:43 +00:00
Neal Norwitz e4b5500e54 Remove duplicate code introduced by fixing bug #678518 2003-02-10 01:08:50 +00:00
Guido van Rossum d58f3fce3d Remove unused variable. 2003-02-09 17:19:18 +00:00
Raymond Hettinger 60eca9331a C Code:
* Removed the ifilter flag wart by splitting it into two simpler functions.
* Fixed comment tabbing in C code.
* Factored module start-up code into a loop.

Documentation:
* Re-wrote introduction.
* Addede examples for quantifiers.
* Simplified python equivalent for islice().
* Documented split of ifilter().

Sets.py:
* Replace old ifilter() usage with new.
2003-02-09 06:40:58 +00:00
Michael W. Hudson df1252dec9 Apply logistix's patch from
[ 678518 ] Another parsermodule validation error
2003-02-08 18:05:10 +00:00
Tim Peters aa7d849c7a timedelta comparison and datetime addition: as the Python implementation
of datetime does, accept instances of subclasses too.
2003-02-08 03:28:59 +00:00
Tim Peters 07534a607b Comparison for timedelta, time, date and datetime objects: __eq__ and
__ne__ no longer complain if they don't know how to compare to the other
thing.  If no meaningful way to compare is known, saying "not equal" is
sensible.  This allows things like

    if adatetime in some_sequence:
and
    somedict[adatetime] = whatever

to work as expected even if some_sequence contains non-datetime objects,
or somedict non-datetime keys, because they only call __eq__.

It still complains (raises TypeError) for mixed-type comparisons in
contexts that require a total ordering, such as list.sort(), use as a
key in a BTree-based data structure, and cmp().
2003-02-07 22:50:28 +00:00
Neal Norwitz 4d933fe392 SF patch #682514, mmapmodule.c write fix for LP64 executables
Make length an int so we get the right value from
PyArg_ParseTuple(args, "s#", &str, &length)

Will backport.
2003-02-07 19:44:56 +00:00
Raymond Hettinger f0c00241ae * Eliminated tuple re-use in imap(). Doing it correctly made the code
too hard to read.
* Simplified previous changes to izip() to make it easier to read.
2003-02-07 07:26:25 +00:00
Raymond Hettinger 2012f174ea SF bug #681003: itertools issues
* Fixed typo in exception message for times()
* Filled in missing times_traverse()
* Document reasons that imap() did not adopt a None fill-in feature
* Document that count(sys.maxint) will wrap-around on overflow
* Add overflow test to islice()
* Check that starmap()'s argument returns a tuple
* Verify that imap()'s tuple re-use is safe
* Make a similar tuple re-use (with safety check) for izip()
2003-02-07 05:32:58 +00:00
Fred Drake dab8b0ad99 Integrate the patch from expat.h 1.51; needed for some C compilers.
Closes SF bug #680797.
2003-02-07 02:15:56 +00:00
Tim Peters 6288e230d8 More typo repair. 2003-02-05 03:53:10 +00:00
Tim Peters 679201467b Typo repair. 2003-02-05 03:46:17 +00:00
Tim Peters 3e667d5452 cPickle: exempt two_tuple from GC -- it's a speed hack, and doesn't
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.
2003-02-04 21:47:44 +00:00
Tim Peters 731098b3ff cPickle now generates proto 2 EXT[124] when appropriate.
Moved such EXT tests as currently exist from TempAbstractPickleTests to
AbstractPickleTests, so that test_cpickle runs them too.
2003-02-04 20:56:09 +00:00
Neal Norwitz 7fe16e79f5 Remove forward static reference since it is not required 2003-02-04 20:46:50 +00:00
Neal Norwitz ce3d34dde7 Whitespace normalization 2003-02-04 20:45:17 +00:00
Marc-André Lemburg 29273c87da Fix for [ 543344 ] Interpreter crashes when recoding; suggested
by Michael Stone (mbrierst).

Python 2.1.4, 2.2.2 candidate.
2003-02-04 19:35:03 +00:00
Walter Dörwald bda1c86daf Use size_t instead of int for various variables to prevent
signed/unsigned comparison warnings on the call to iconv().

Fix comment typos.

From SF patch #680146.
2003-02-04 18:02:28 +00:00
Tim Peters fa05ce3c1d Typo in comment. 2003-02-04 05:20:32 +00:00
Tim Peters 2d62965734 cPickle can load pickles using proto 2 EXT[124] now, but can't yet
generate these opcodes.
2003-02-04 05:06:17 +00:00
Guido van Rossum d4b920c8bd Rename the extension registry variables to have leading underscores --
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.
2003-02-04 01:54:49 +00:00
Tim Peters 0dd23aa539 Typo repair. 2003-02-04 00:30:46 +00:00
Tim Peters 5b7da39f23 Brought some module variables into synch with pickle.py's current values.
Imported the extension-registry dicts from copy_reg.py, in preparation for
tackling EXT[124].
2003-02-04 00:21:07 +00:00
Tim Peters 0c7c48e02c load_counted_long(): Changed a ValueError to an UnpicklingError, just
because it seems more consistent with the rest of the code.

cPickle_PyMapping_HasKey():  This extern function isn't used anywhere in
Python or Zope, so got rid of it.
2003-02-03 22:07:24 +00:00
Guido van Rossum 7d9ea5013f - Thanks to Scott David Daniels, a subtle bug in how the zlib
extension implemented flush() was fixed.  Scott also rewrite the
  zlib test suite using the unittest module.  (SF bug #640230 and
  patch #678531.)

Backport candidate I think.
2003-02-03 20:45:52 +00:00
Tim Peters e0a3907904 PDATA_PUSH and PDATA_APPEND. documented, and reformatted for better
readability.

load_bool():  Now that I know the intended difference between _PUSH and
_APPEND, used the right one.

Pdata_grow():  Squashed out a redundant overflow test.
2003-02-03 15:45:56 +00:00
Gregory P. Smith 3ed7b03224 version 4.1.4 (4.1.3 just released) 2003-02-03 04:28:26 +00:00
Tim Peters 1d63c9f151 cPickle support for TUPLE[123]. Incidentally plugged several undetected
overflow holes in Pdata_grow().
2003-02-02 20:29:39 +00:00
Tim Peters 0bc93f5c8b Massive edits. If p is a pointer to a struct, and p->f is a pointer to
a function, then

    p->f(arg1, arg2, ...)

is semantically the same as

    (*p->f)(arg1, arg2, ...)

Changed all instances of the latter into the former.  Given how often
the code embeds this kind of expression in an if test, the unnecessary
parens and dereferening operator were a real drag on readability.
2003-02-02 18:29:33 +00:00
Tim Peters ac5687a515 Minor cleanup, mostly adding horizontal whitespace, and breaking apart
embedded assignments, for readability.
2003-02-02 18:08:34 +00:00
Tim Peters 3c67d795ef Implemented proto 2 NEWTRUE and NEWFALSE in cPickle. 2003-02-02 17:59:11 +00:00
Neal Norwitz d156c2d782 Get ossaudiodev to compile on freebsd 4.7 2003-02-02 17:59:06 +00:00
Tim Peters 70b02d79f9 Beefed up the tests by putting in more "for proto in protocols:" outer
loops.  Renamed DATA and BINDATA to DATA0 and DATA1.  Included
disassemblies, but noted why we can't test them.  Added XXX comment to
cPickle about a mysterious comment, where pickle and cPickle diverge
in how they number PUT indices.
2003-02-02 17:26:40 +00:00
Neal Norwitz 529baf2b57 Fix compiler warning 2003-02-02 17:08:33 +00:00
Tim Peters 87482ea055 dump(): Added asserts that self->proto is sane. 2003-02-02 16:16:30 +00:00
Tim Peters 9b1e03ff4b dump(): Fixed a stupid bug in new code. It wasn't possible for the bug
to have an effect before protocol 3 is invented, so no test can be
written for this (yet).
2003-02-02 16:14:23 +00:00
Tim Peters 4190fb8429 Add cPickle support for PROTO. Duplicated PROTO/LONG1/LONG4 code in
the hitherto unknown (to me) noload() cPickle function, which is (a)
something we don't test at all, and (b) pickle.py doesn't have.
2003-02-02 16:09:05 +00:00
Fred Drake 06dd8cf5e4 Fix memory leak: free memory storing the content model passed to the
ElementDeclHandler by Expat.
Fixes SF bug #676990.
2003-02-02 03:54:17 +00:00
Tim Peters ee1a53cbb1 cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments.  Fixed an undetected-overflow bug in readline_file().

longobject.c:  Fixed a really stupid bug in the new _PyLong_NumBits.

pickle.py:  Fixed stupid bug in save_long():  When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4():  they *returned* the unpickled long instead of pushing
it on the stack.  The return values were ignored.  Tests passed
before only because save_long() pickled the long twice.

Fixed bugs in encode_long().

Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time.  I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that.  It would be more valuable to make long(string, 16) linear time.

pickletester.py:  Added a global "protocols" vector so tests can try
all the protocols in a sane way.  Changed test_ints() and test_unicode()
to do so.  Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle:  cPickle proto 2 for longs is linear-time).
2003-02-02 02:57:53 +00:00
Tim Peters 5bd2a79b22 The C pickle now knows how to deal with a proto= argument. Assorted
code cleanups, and purged more references to text-vs-binary modes.
2003-02-01 16:45:06 +00:00
Tim Peters 040e033796 Removed needless include of errno.h. 2003-02-01 06:30:12 +00:00
Tim Peters 64c04d1df3 The module docstring had an RCS ID from 1999 embedded in it. Enough
already <wink>.
2003-02-01 06:27:59 +00:00
Tim Peters cba30e2c96 Trimmed trailing whitespace. 2003-02-01 06:24:36 +00:00
Tim Peters 797ec24e87 Added #defines for proto 2 opcodes; gave the Pickler a proto member;
removed woefully inadequate opcode docs and pointed to pickletools.py
instead.
2003-02-01 06:22:36 +00:00
Tim Peters 70533e28ad New functions alloc_{time,datetime}. Got rid of all setstate-like
functions.  Reworked {time,datetime}_new() to do what their corresponding
setstates used to do in their state-tuple-input paths, but directly,
without constructing an object with throwaway state first.  Tightened
the "is this a state tuple input?" paths to check the presumed state
string-length too, and to raise an exception if the optional second state
element isn't a tzinfo instance (IOW, check these paths for type errors
as carefully as the normal paths).
2003-02-01 04:40:04 +00:00
Tim Peters b57f8f02ba There's no good reason for datetime objects to expose __getstate__()
anymore either, so don't.  This also allows to get rid of obscure code
making __getnewargs__ identical to __getstate__ (hmm ... hope there
wasn't more to this than I realize!).
2003-02-01 02:54:15 +00:00
Tim Peters 1f1b2d2e68 Removed all uses of the out-of-favor __safe_for_unpickling__ magic
attr, and copy_reg.safe_constructors.
2003-02-01 02:16:37 +00:00
Tim Peters 371935fc06 All over: changed comments to reflect pickling is straightforward now,
not the maze it was.
2003-02-01 01:52:50 +00:00