40 Commits

Author SHA1 Message Date
Andrew M. Kuchling
165e797817 [Backport r51224 | neal.norwitz]
Move the assert which checks for a NULL pointer first.
Klocwork #274.
2006-10-05 17:22:15 +00:00
Andrew M. Kuchling
68e1e0372b [Backport r51255 | neal.norwitz]
Really address the issue of where to place the assert for leftblock.
(Followup of Klocwork 274)
2006-10-05 17:06:59 +00:00
Andrew M. Kuchling
e7031223e3 [Backport of rev. 42093 by neal.norwitz]
Check return result from Py_InitModule*().  This API can fail.

Probably should be backported.
2006-09-27 19:17:32 +00:00
Georg Brandl
66e75ac6e0 Disallow keyword arguments for type constructors that don't use them
(fixes #1119418).
2005-08-26 06:43:16 +00:00
Raymond Hettinger
952f8808b2 SF patch #1062279: deque pickling problems
(Contributed by Dima Dorfman.)

* Support pickling of dictionaries in instances of deque subclasses.
* Support pickling of recursive deques.
2004-11-09 07:27:35 +00:00
Raymond Hettinger
7d112df94f Bump-up block size. 2004-11-02 02:11:35 +00:00
Raymond Hettinger
dcb9d9467c Simplify delitem() code by calling rotate() directly instead of using
arguments passed through tuples.
2004-10-09 16:02:18 +00:00
Raymond Hettinger
c5fa992069 Armin's patch to prevent overflows. 2004-10-06 17:51:54 +00:00
Armin Rigo
974d757af1 Upon insertion, if memory runs out, the deque was left in a corrupted state.
deque_item(): a performance bug: the linked list of blocks was followed
from the left in most cases, because the test (i < (deque->len >> 1)) was
after "i %= BLOCKLEN".

deque_clear(): replaced a call to deque_len() with deque->len; not sure what
this call was here for, nor if all compilers under the sun would inline it.

deque_traverse(): I belive that it could be called by the GC when the deque
has leftblock==rightblock==NULL, because it is tracked before the first block
is allocated (though closely before).  Still, a C extension module subclassing
deque could provide its own tp_alloc that could trigger a GC collection after
the PyObject_GC_Track()...

deque_richcompare(): rewrote to cleanly check for end-of-iterations instead of
relying on deque.__iter__().next() to succeed exactly len(deque) times -- an
assumption which can break if deques are subclassed.  Added a test.

I wonder if the length should be explicitely bounded to INT_MAX, with
OverflowErrors, as in listobject.c.  On 64-bit machines, adding more than
INT_MAX in the deque will result in trouble.  (Note to anyone/me fixing
this: carefully check for overflows if len is close to INT_MAX in the
following functions: deque_rotate(), deque_item(), deque_ass_item())
2004-10-02 13:59:34 +00:00
Raymond Hettinger
d1b3d88bf3 * Bulletproof the method for detecting mutations during iteration.
The previous approach was too easily fooled (a rotate() sufficed).

* Use it->counter to determine when iteration is complete.  The
  previous approach was too complex.

* Strengthen an assertion and add a comment here or there.
2004-10-02 00:43:13 +00:00
Raymond Hettinger
77e8bf1ca4 Restore the block length and add a comment. 2004-10-01 15:25:53 +00:00
Raymond Hettinger
4ca4c7c8cc Clarify the relationship between indices. 2004-10-01 15:14:39 +00:00
Raymond Hettinger
61f05fb96d * Elaborate on the invariant comments and make them more precise.
* Change the centering by one to make it possible to test the module
  with BLOCKLEN's as low as two.  Testing small blocks makes end-point
  errors surface more readily.
2004-10-01 06:24:12 +00:00
Tim Peters
10c7e86454 deque_traverse(): If the deque had one block, and its rightindex was
BLOCKLEN-1, this assert-failed in a debug build, or went wild with a
NULL pointer in a release build.  Reported on c.l.py by Stefan Behnel.
2004-10-01 02:01:04 +00:00
Tim Peters
d6e0032768 Typos in new comments. 2004-10-01 01:35:54 +00:00
Tim Peters
d8768d3294 Document some reverse-engineered invariants and pragmatic hints. 2004-10-01 01:32:53 +00:00
Tim Peters
6f85356ff7 Definition consistency. 2004-10-01 01:04:50 +00:00
Tim Peters
1065f750cb Trimmed trailing whitespace. 2004-10-01 01:03:29 +00:00
Raymond Hettinger
e9c89e8308 Silence a GCC unused variable warning in debug builds. 2004-07-19 00:10:24 +00:00
Raymond Hettinger
67115a2b02 Apply VISIT macro. 2004-07-15 21:32:18 +00:00
Nicholas Bastin
9ba301e589 Moved SunPro warning suppression into pyport.h and out of individual
modules and objects.
2004-07-15 15:54:05 +00:00
Raymond Hettinger
a435c53e13 * balance the left/right search for getitem.
* use assertions instead of tests after internal calls that can't fail.
* expand test coverage
2004-07-09 04:10:20 +00:00
Raymond Hettinger
616f4f61ba Add a comment with implementation notes. 2004-06-26 04:42:06 +00:00
Nicholas Bastin
1ce9e4cfc1 Fixed end-of-loop code not reached warning when using SunPro C 2004-06-17 18:27:18 +00:00
Raymond Hettinger
691d80532b Make sets and deques weak referencable. 2004-05-30 07:26:47 +00:00