Commit Graph

1942 Commits

Author SHA1 Message Date
Guido van Rossum 52b2705e9c Ouch, it's Carlo Verre, not Verre Carlo. 2003-04-15 20:05:10 +00:00
Guido van Rossum 0fc8f00252 - pythunrun.c, Py_Finalize(): move the call to _Py_PrintReferences()
even farther down, to just before the call to
  _PyObject_DebugMallocStats().  This required the following changes:

- pystate.c, PyThreadState_GetDict(): changed not to raise an
  exception or issue a fatal error when no current thread state is
  available, but simply return NULL without raising an exception
  (ever).

- object.c, Py_ReprEnter(): when PyThreadState_GetDict() returns NULL,
  don't raise an exception but return 0.  This means that when
  printing a container that's recursive, printing will go on and on
  and on.  But that shouldn't happen in the case we care about (see
  first bullet).

- Updated Misc/NEWS and Doc/api/init.tex to reflect changes to
  PyThreadState_GetDict() definition.
2003-04-15 15:12:39 +00:00
Guido van Rossum 4dcdb78c6f Close off the "Verre Carlo hack" as discussed on python-dev. 2003-04-14 21:46:03 +00:00
Guido van Rossum 2fd02eb80f super_getattro(): kill some dead code; explain a mystery. 2003-04-14 21:20:26 +00:00
Guido van Rossum 3a3cca5b82 - list.insert(i, x) now interprets negative i as it would be
interpreted by slicing, so negative values count from the end of the
  list.  This was the only place where such an interpretation was not
  placed on a list index.
2003-04-14 20:58:14 +00:00
Neal Norwitz ffe33b7f24 Attempt to make all the various string *strip methods the same.
* Doc - add doc for when functions were added
 * UserString
 * string object methods
 * string module functions
'chars' is used for the last parameter everywhere.

These changes will be backported, since part of the changes
have already been made, but they were inconsistent.
2003-04-10 22:35:32 +00:00
Jeremy Hylton d06483c2f6 Missing DECREF. 2003-04-09 21:01:42 +00:00
Guido van Rossum 2fb9fdc96a Make it possible to call instancemethod() with 2 arguments. 2003-04-09 19:35:08 +00:00
Guido van Rossum a7132189d2 Reformat a few docstrings that caused line wraps in help() output. 2003-04-09 19:32:45 +00:00
Guido van Rossum 00bf8280f5 property_traverse() should also traverse into prop_doc -- there's no
typecheck that guarantees it's a string, and BTW string subclasses
could hide references.
2003-04-09 17:05:33 +00:00
Jeremy Hylton 400d8ee6fa Make staticmethods and classmethods participate in GC.
If a class was defined inside a function, used a static or class
method, and used super() inside the method body, it would be caught in
an uncollectable cycle.  (Simplified version: The static/class method
object would point to a function object with a closure that referred
to the class.)

Bugfix candidate.
2003-04-08 21:28:47 +00:00
Tim Peters df875b99fc New private API function _PyInstance_Lookup. gc will use this to figure
out whether __del__ exists, without executing any Python-level code.
2003-04-07 17:51:59 +00:00
Raymond Hettinger f394df47fd SF bug #699934: Obscure error message
mwh pointed out that the error message did not
make sense if obtained by rearranging the bases.
2003-04-06 19:13:41 +00:00
Walter Dörwald 44f527fea4 Change formatchar(), so that u"%c" % 0xffffffff now raises
an OverflowError instead of a TypeError to be consistent
with "%c" % 256. See SF patch #710127.
2003-04-02 16:37:24 +00:00
Walter Dörwald 43440a621e Fix PyString_Format() so that '%c' % u'a' returns u'a'
instead of raising a TypeError. (From SF patch #710127)

Add tests to verify this is fixed.

Add various tests for '%c' % int.
2003-03-31 18:07:50 +00:00
Martin v. Löwis b9a0f91218 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285. 2003-03-29 10:06:18 +00:00
Guido van Rossum 8d24ee97df Refactoring: rename update_these_slots() into update_subclasses() and
generalize to take a callback function and a void * data argument.
This might come in handy later... :-)
2003-03-24 23:49:49 +00:00
Tim Peters 51f8d38185 Typo in comment. 2003-03-23 18:06:08 +00:00
Tim Peters 7571a0fbcf Improved new Py_TRACE_REFS gimmicks.
Arranged that all the objects exposed by __builtin__ appear in the list
of all objects.  I basically peed away two days tracking down a mystery
leak in sys.gettotalrefcount() in a ZODB app (== tons of code), because
the object leaking the references didn't appear in the sys.getobjects(0)
list.  The object happened to be False.  Now False is in the list, along
with other popular & previously missing leak candidates (like None).
Alas, we still don't have a choke point covering *all* Python objects,
so the list of all objects may still be incomplete.
2003-03-23 17:52:28 +00:00
Tim Peters bf9b24464e slot_sq_contains(): This leaked a reference to the result of calling
__contains__().

Bugfix candidate.
2003-03-23 05:35:36 +00:00
Tim Peters 36eb4dfb81 Refactored some of the Py_TRACE_REFS code. New private API function
_Py_AddToAllObjects() that simply inserts an object at the front of
the doubly-linked list of all objects.  Changed PyType_Ready() (the
 closest thing we've got to a choke point for type objects) to call
that.
2003-03-23 03:33:13 +00:00
Tim Peters 3e40c7ff5b Oops! Used a wrong preprocessor symbol. 2003-03-23 03:04:32 +00:00
Tim Peters 78be7993b6 When Py_TRACE_REFS is defined, a list of all live objects is maintained in
a doubly-linked list, exposed by sys.getobjects().  Unfortunately, it's not
really all live objects, and it seems my fate to bump into programs where
sys.gettotalrefcount() keeps going up but where the reference leaks aren't
accounted for by anything in the list of all objects.

This patch helps a little:  if COUNT_ALLOCS is also defined, from now on
type objects will also appear in this list, provided at least one object
of a type has been allocated.
2003-03-23 02:51:01 +00:00
Tim Peters f1ed934278 _PyFloat_Pack4(): Removed needless call of floor(). 2003-03-21 17:10:03 +00:00
Tim Peters 9905b943f7 New private API functions _PyFloat_{Pack,Unpack}(4,8}. This is a
refactoring to get all the duplicates of this delicate code out of the
cPickle and struct modules.
2003-03-20 20:53:32 +00:00
Raymond Hettinger 1da1dbf458 Renamed PyObject_GenericGetIter to PyObject_SelfIter
to more accurately describe what the function does.

Suggested by Thomas Wouters.
2003-03-17 19:46:11 +00:00
Raymond Hettinger 0153826964 Created PyObject_GenericGetIter().
Factors out the common case of returning self.
2003-03-17 08:24:35 +00:00
Raymond Hettinger 83245b5828 SF bug #699934: Obscure error message
Clarify error message for mro conflicts.
2003-03-12 04:25:42 +00:00
Raymond Hettinger c8df5780e1 Sf patch #700047: unicode object leaks refcount on resizing
Contributed by Hye-Shik Chang.
2003-03-09 07:30:43 +00:00
Guido van Rossum e5c691abe3 - The extended type structure used for heap types (new-style
classes defined by Python code using a class statement) is now
  exported from object.h as PyHeapTypeObject.  (SF patch #696193.)
2003-03-07 15:13:17 +00:00
Raymond Hettinger a3e1e4cd79 SF patch #693753: fix for bug 639806: default for dict.pop
(contributed by Michael Stone.)
2003-03-06 23:54:28 +00:00
Guido van Rossum 4eadfa2b2e Fix from Greg Chapman from SF bug #695651: a complex subclass
constructor, when passed a single complex argument, returns the
argument unchanged.  This should be done only for the complex base
class; a complex subclass should of course cast the value to the
subclass in this case.

The fix also revealed a segfault in complex_getnewargs(): the argument
for the Py_BuildValue() format code "D" is the *address* of a
Py_complex struct, not the value.  (This corroborated by the API
documentation.)

I expect this needs to be backported to 2.2.3.
2003-03-02 13:51:47 +00:00
Raymond Hettinger 8049dde8d7 Removed duplicate test from inner loop.
The PyIter_Check is already performed by PyObject_GetIter.
2003-03-01 01:44:32 +00:00
Neal Norwitz d5a65a77cf Fix SF bug #689659, 64-bit int and long hash keys incompatible
On a 64-bit machine, a dictionary could contain duplicate int/long keys
if the value was > 2**32.
2003-02-23 23:11:41 +00:00
Guido van Rossum 036f999669 Implementing the salient parts of __reduce_ex__ in C.
This still falls back to helpers in copy_reg for:
   - pickle protocols < 2
   - calculating the list of slot names (done only once per class)
   - the __newobj__ function (which is used as a token but never called)
2003-02-21 22:02:54 +00:00
Thomas Heller 850566b644 Strange control flow in PyInt_AsLong. When nb_int is called inside
the PyInt_AsLong function, and this returns a long, the value is first
retrieved with PyLong_AsLong, but afterwards overwritten by a call to
PyInt_AS_LONG.

Fixes SF #690253.
2003-02-20 20:32:11 +00:00
Guido van Rossum 90195e2616 PyObject_Generic{Get,Set}Attr:
Don't access tp_descr_{get,set} of a descriptor without checking the
flag bits of the descriptor's type.  While we know that the main type
(the type of the object whose attribute is being accessed) has all the
right flag bits (or else PyObject_Generic{Get,Set}Attr wouldn't be
called), we don't know that for its class attributes!

Will backport to 2.2.
2003-02-19 03:19:29 +00:00
Guido van Rossum c53f009f94 Introducing __reduce_ex__, which is called with a protocol number argument
if it exists in preference over __reduce__.  Now Tim can go implement this
in cPickle.c.
2003-02-18 22:05:12 +00:00
Tim Peters 97e5ff555e Removed unreferenced label. 2003-02-18 19:32:50 +00:00
Guido van Rossum 8e80a72be4 The recent changes to super(), in particular supercheck(), broke when
using super() for an instance in a metaclass situation.  Because the
class was a metaclass, the instance was a class, and hence the
PyType_Check() branch was taken.  But this branch didn't apply.  Make
it so that if this branch doesn't apply, the other branch is still
tried.  All tests pass.
2003-02-18 19:22:22 +00:00
Guido van Rossum 6b29c0147b Make __module__ writable except in restricted mode (like for classic classes). 2003-02-18 17:18:35 +00:00
Jeremy Hylton ff71c98449 Make __module__ settable on functions and methods. 2003-02-18 17:02:15 +00:00
Guido van Rossum fb50d3ffa1 default_3way_compare(): use PyNumber_Check(), rather than testing for
tp_as_number directly.
2003-02-18 16:40:09 +00:00
Guido van Rossum 6921eca227 Make PyNumber_Check() a bit more careful, since all sorts of things
now have tp_as_number.  Check for nb_int or nb_float.
2003-02-18 16:36:28 +00:00
Neal Norwitz 0732301738 Add closing ) in comment 2003-02-15 14:45:12 +00:00
Tim Peters 080c88b912 cPickle.c, load_build(): Taught cPickle how to pick apart
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.
2003-02-15 03:01:11 +00:00
Guido van Rossum 298e421453 SF patch #685738 by Michael Stone.
This changes the default __new__ to refuse arguments iff tp_init is the
default __init__ implementation -- thus making it a TypeError when you
try to pass arguments to a constructor if the class doesn't override at
least __init__ or __new__.
2003-02-13 16:30:16 +00:00
Guido van Rossum 47710656e5 Issue a warning when int('0...', 0) returns an int with the sign
folded; this will change in Python 2.4.  On a 32-bit machine, this
happens for 0x80000000 through 0xffffffff, and for octal constants in
the same value range.  No warning is issued if an explicit base is
given, *or* if the string contains a sign (since in those cases no
sign folding ever happens).
2003-02-12 20:48:22 +00:00
Guido van Rossum a89d10edc9 Implement another useful feature for proxies: in super(X, x), x may
now be a proxy for an X instance, as long as issubclass(x.__class__, X).
2003-02-12 03:58:38 +00:00
Guido van Rossum e5b130bcdb Add missing cast in previous fix. 2003-02-12 03:36:05 +00:00
Guido van Rossum 03bc7d3c4d SF #532767: isinstance(x, X) should work when x is a proxy for an X
instance, as long as x.__class__ is X or a subclass thereof.
Did a little cleanup of PyObject_IsInstance() too.
2003-02-12 03:32:58 +00:00
Neal Norwitz ec74f2fda7 Add more missing PyErr_NoMemory() after failled memory allocs 2003-02-11 23:05:40 +00:00
Guido van Rossum eea4718e81 Fix from SF #681367: inherit tp_as_buffer. This only applies to C
types -- Python types already inherited this.
2003-02-11 20:39:59 +00:00
Guido van Rossum b6e5a0c658 Put proper tests in classmethod_get(). Remove the type argument to
descr_check(); it wasn't useful.  Change the type argument of the
various _get() methods to PyObject * because the call signature of
tp_descr_get doesn't guarantee its type.
2003-02-11 18:44:42 +00:00
Guido van Rossum 6bae46d8c1 Refactor instancemethod_descr_get() to (a) be more clear, (b) be safe
in the light of weird args, and (c) not to expect None (which is now
changed to NULL by slot_tp_descr_get()).
2003-02-11 18:43:00 +00:00
Guido van Rossum 9af48ff44e Inline create_specialmethod() -- since METH_CLASS is done differently
now, it was only called once, and its existence merely obfuscates the
control flow.
2003-02-11 17:12:46 +00:00
Guido van Rossum 82ed25c15a Add basic arg sanity checking to wrap_descr_get(). This is called
when Python code calls a descriptor's __get__ method.  It should
translate None to NULL in both argument positions, and insist that at
least one of the argument positions is not NULL after this
transformation.
2003-02-11 16:25:43 +00:00
Guido van Rossum 3f50cdc05e Get rid of the "bozo" __getstate__ that was inserted when __slots__
was used.  This simplifies some logic in copy_reg.py (used by
pickling).  It also broke a test, but this was rewritten to test the
new feature. :-)
2003-02-10 21:31:27 +00:00
Guido van Rossum f6c9ba8457 Fold long lines. 2003-02-10 16:05:43 +00:00
Neal Norwitz de8b94c3e1 Fix SF bug #683467, 'int' ability to generate longs not inherited
When subclassing from an int but not overriding __new__,
long values were not converted properly.  Try to convert
longs into an int.
2003-02-10 02:12:43 +00:00
Walter Dörwald f6b56aecad Fix two refcounting bugs 2003-02-09 23:42:56 +00:00
Neal Norwitz cb3319f61e SF patch #683187, fix universal newline problems on error 2003-02-09 01:10:02 +00:00
Andrew M. Kuchling c9172d3832 Comment typo fix 2003-02-06 15:22:49 +00:00
Guido van Rossum ce8bcd8405 Fix for SF #668433. I'm not explaining it here; ample comments are in
the code.
2003-02-05 22:39:45 +00:00
Jeremy Hylton bd5cbf866f Refactor the logic for setting f_builtins.
For the case where the current globals match the previous frame's
globals, eliminates three tests in two if statements.  For the case
where we just get __builtins__ from a module, eliminate a couple of
tests.
2003-02-05 22:39:29 +00:00
Tim Peters 18e7083cda SF bug 681122: Built-in function dir() causes refcount leak in baseclasses.
merge_class_dict():  This was missing a decref.

Bugfix candidate.
2003-02-05 19:35:19 +00:00
Guido van Rossum 004a65c9b1 _PyLong_Sign(): remove an assert that needed a variable ndigits that
wasn't used outside the assert (and hence caused a compiler warning
about an unused variable in NDEBUG mode).  The assert wasn't very
useful any more.

_PyLong_NumBits(): moved the calculation of ndigits after asserting
that v != NULL.
2003-02-03 15:28:19 +00:00
Tim Peters 1a3b19a6e9 long_from_binary_base(): Sped this a little by computing the # of bits
needed outside the first loop.
2003-02-02 17:33:53 +00:00
Tim Peters efb9625b81 Tightened a too-generous assert. 2003-02-02 08:05:32 +00:00
Tim Peters bf2674be0e long(string, base) now takes time linear in len(string) when base is a
power of 2.  Enabled the tail end of test_long() in pickletester.py
because it no longer takes forever when run from test_pickle.py.
2003-02-02 07:51:32 +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 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 08a1d9cafc Squash compiler wng about signed/unsigned comparison mismatch. 2003-01-31 21:45:13 +00:00
Jeremy Hylton 4f0dcc9a9a Provide __module__ attributes for functions defined in C and Python.
__module__ is the string name of the module the function was defined
in, just like __module__ of classes.  In some cases, particularly for
C functions, the __module__ may be None.

Change PyCFunction_New() from a function to a macro, but keep an
unused copy of the function around so that we don't change the binary
API.

Change pickle's save_global() to use whichmodule() if __module__ is
None, but add the __module__ logic to whichmodule() since it might be
used outside of pickle.
2003-01-31 18:33:18 +00:00
Walter Dörwald 2e0b18af30 Change the treatment of positions returned by PEP293
error handers in the Unicode codecs: Negative
positions are treated as being relative to the end of
the input and out of bounds positions result in an
IndexError.

Also update the PEP and include an explanation of
this in the documentation for codecs.register_error.

Fixes a small bug in iconv_codecs: if the position
from the callback is negative *add* it to the size
instead of substracting it.

From SF patch #677429.
2003-01-31 17:19:08 +00:00
Tim Peters 5b8132ffa3 _PyLong_NumBits(): The definition of this was too specific to the quirky
needs of pickling longs.  Backed off to a definition that's much easier
to understand.  The pickler will have to work a little harder, but other
uses are more likely to be correct <0.5 wink>.

_PyLong_Sign():  New teensy function to characterize a long, as to <0, ==0,
or >0.
2003-01-31 15:52:05 +00:00
Guido van Rossum 5d9113d8be Implement appropriate __getnewargs__ for all immutable subclassable builtin
types.  The special handling for these can now be removed from save_newobj().
Add some testing for this.

Also add support for setting the 'fast' flag on the Python Pickler class,
which suppresses use of the memo.
2003-01-29 17:58:45 +00:00
Tim Peters baefd9e552 Added new private API function _PyLong_NumBits. This will be used at the
start for the C implemention of new pickle LONG1 and LONG4 opcodes (the
linear-time way to pickle a long is to call _PyLong_AsByteArray, but
the caller has no idea how big an array to allocate, and correct
calculation is a bit subtle).
2003-01-28 20:37:45 +00:00
Neal Norwitz abcb0c03ad Fix SF bug# 676155, RuntimeWarning with tp_compare
Check return value of PyLong_AsDouble(), it can return an error.
2003-01-28 19:21:24 +00:00
Tim Peters 4440f22e98 Recursive compare machinery: The code that intended to exempt tuples
was broken because new-in-2.3 code added a tp_as_mapping slot to tuples.
Repaired that.

Added basic docs to check_recursion().

The code that intended to exempt tuples and strings was also broken here,
and in 2.2:  these should use PyXYZ_CheckExact(), not PyXYZ_Check() -- we
can't know whether subclass instances are immutable.  This part (and this
part alone) is a bugfix candidate.
2003-01-20 16:54:59 +00:00
Neal Norwitz fa56e2dc40 SF # 669553, fix memory (ref) leaks
Will backport.
2003-01-19 15:40:09 +00:00
Raymond Hettinger 5d5e7c0e34 SF patch #664192 bug #661913: inconsistent error messages between string
and unicode

Patch by Christopher Blunck.
2003-01-15 05:32:57 +00:00
Neal Norwitz 1a9975014f Fix SF bug #667147, Segmentation fault printing str subclass
Fix infinite recursion which occurred when printing an object
whose __str__() returned self.

Will backport
2003-01-13 20:13:12 +00:00
Walter Dörwald adc727490b Fix charmapencode_lookup(), so that a None value in the mapping
is treated as "character maps to <undefined>" and not as
"character mapping must return integer, None or str".
2003-01-08 22:01:33 +00:00
Walter Dörwald 034d97605d Remove variable owned from PyUnicode_FromEncodedObject, which is unused
(except for Py_DECREF calls) since the introduction of __unicode__.
2003-01-08 20:38:39 +00:00
Guido van Rossum 373c7412f2 Fix for SF bug #642358: only provide a new with a __dict__ or
__weaklist__ descriptor if we added __dict__ or __weaklist__,
respectively.  With unit test.
2003-01-07 13:41:37 +00:00
Guido van Rossum cd118803b5 Add a refinement to SLOT1BINFULL() that fixes the problem reported in
SF bug #623669: only try (e.g.) __rdiv__ before __div__ if the right
class actually overrides it.
2003-01-06 22:57:47 +00:00
Raymond Hettinger 0a2f849b79 GvR's idea to use memset() for the most common special case of repeating
a single character.  Shaves another 10% off the running time by avoiding
the lg2(N) loops and cache effects for the other cases.
2003-01-06 22:42:41 +00:00
Raymond Hettinger 698258a199 Optimize string_repeat.
Christian Tismer pointed out the high cost of the loop overhead and
function call overhead for 'c' * n where n is large.  Accordingly,
the new code only makes lg2(n) loops.

Interestingly, 'c' * 1000 * 1000 ran a bit faster with old code.  At some
point, the loop and function call overhead became cheaper than invalidating
the cache with lengthy memcpys.  But for more typical sizes of n, the new
code runs much faster and for larger values of n it runs only a bit slower.
2003-01-06 10:33:56 +00:00
Tim Peters 541ceec3e6 PyCFunction_Call(): Combined two switch cases w/ identical bodies. 2003-01-05 07:22:44 +00:00
Raymond Hettinger bf43f8af35 SF Patch #661440: Refactor and streamline PyCFunction_Call
Refactor code in PyCFunction_Call giving a modest (tiny) speed boost,
a slight improvement in semantics (now detects invalid flag combinations),
and (arguably) improved clarity (making it blindingly clear which flag
combinations are allowed).  All this comes at a cost of a few lines of
code duplication.

* Folded test for METH_KEYWORDS into the switch/case.
* Deferred testing for an empty dictionary until when and where needed.
* Make a similar deferral for filling the "size" variable.
* Inverted the dictionary test so that the common case falls though
  instead of making a jump.
2003-01-04 00:37:53 +00:00
Greg Ward 6f2bb2362a Grammatical fix in comment. 2003-01-03 21:22:08 +00:00
Martin v. Löwis af6a27a704 Allow PyFile_GetLine() to return Unicode objects. Fixes #660165. 2003-01-03 19:16:14 +00:00
Skip Montanaro 4abd5f0fce Allow list sort's comparison function to explicitly be None. See SF patch
661092.
2003-01-02 20:51:08 +00:00
Guido van Rossum a3a243e977 Merge to trunk from release branch:
Plug the leak that Tim just reported.
2002-12-31 19:50:03 +00:00
Guido van Rossum 768158c11b Fix an out-of-bound index in pmerge() discovered by Zooko (SF bug
645404).  I'm not 100% sure this is the right fix, so I'll keep the
bug report open for Samuele, but this fixes the index error and passes
the test suite (and I can't see why it *shouldn't* be the right fix
:-).
2002-12-31 16:33:01 +00:00
Neal Norwitz b2501f4cd1 Since the *_Init() are private, prefix with _, suggested by Skip 2002-12-31 03:42:13 +00:00
Neal Norwitz c91ed400e0 SF #561244, Micro optimizations
Initialize the small integers and __builtins__ in startup.
This removes some if conditions.
Change XDECREF to DECREF for values which shouldn't be NULL.
2002-12-30 22:29:22 +00:00
Neil Schemenauer 0df295889c Consolidate the int and long sequence repeat code. Before the change,
integers checked for integer overflow but longs did not.
2002-12-30 20:19:02 +00:00
Neil Schemenauer d4b0fea43a Always try nb_* slots before trying sq_concat, sq_inplace_concat, sq_repeat,
andsq_inplace_repeat.  This fixes a number of corner case bugs (see #624807).

Consolidate the int and long sequence repeat code.  Before the change, integers
checked for integer overflow but longs did not.
2002-12-30 20:18:15 +00:00