Commit Graph

73 Commits

Author SHA1 Message Date
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Guido van Rossum e92e610a9e Christian Tismer -- total rewrite on trashcan code.
Improvements:
- does no longer need any extra memory
- has no relationship to tstate
- works in debug mode
- can easily be modified for free threading (hi Greg:)

Side effects:
Trashcan does change the order of object destruction.
Prevending that would be quite an immense effort, as
my attempts have shown. This version works always
the same, with debug mode or not. The slightly
changed destruction order should therefore be no problem.

Algorithm:
While the old idea of delaying the destruction of some
obejcts at a certain recursion level was kept, we now
no longer aloocate an object to hold these objects.
The delayed objects are instead chained together
via their ob_type field. The type is encoded via
ob_refcnt. When it comes to the destruction of the
chain of waiting objects, the topmost object is popped
off the chain and revived with type and refcount 1,
then it gets a normal Py_DECREF.

I am confident that this solution is near optimum
for minimizing side effects and code bloat.
2000-04-24 15:40:53 +00:00
Jeremy Hylton 4a3dd2dcc2 Fix PR#7 comparisons of recursive objects
Note that comparisons of deeply nested objects can still dump core in
extreme cases.
2000-04-14 19:13:24 +00:00
Guido van Rossum b244f6950b Marc-Andre Lemburg:
* TypeErrors during comparing of mixed type arguments including
  a Unicode object are now masked (just like they are for all
  other combinations).
2000-04-10 13:42:33 +00:00
Guido van Rossum 5db862dd0c Skip Montanaro: add string precisions to calls to PyErr_Format
to prevent possible buffer overruns.
2000-04-10 12:46:51 +00:00
Guido van Rossum 13ff8eb493 Christian Tismer:
Added "better safe than sorry" patch to the new
trashcan code in object.c, to ensure that tstate
is not touched when it might be undefined.
2000-03-25 18:39:19 +00:00
Guido van Rossum d724b23420 Christian Tismer's "trashcan" patch:
Added wrapping macros to dictobject.c, listobject.c, tupleobject.c,
frameobject.c, traceback.c that safely prevends core dumps
on stack overflow. Macros and functions in object.c, object.h.
The method is an "elevator destructor" that turns cascading
deletes into tail recursive behavior when some limit is hit.
2000-03-13 16:01:29 +00:00
Guido van Rossum 4c08d554b9 Many changes for Unicode, by Marc-Andre Lemburg. 2000-03-10 22:55:18 +00:00
Guido van Rossum bffd683f73 The rest of the changes by Trent Mick and Dale Nagata for warning-free
compilation on NT Alpha.  Mostly added casts etc.
2000-01-20 22:32:56 +00:00
Guido van Rossum 687ef6e70b On Linux, one sometimes sees spurious errors after interrupting
previous output.  Call clearerr() to prevent past errors affecting our
ferror() test later, in PyObject_Print().  Suggested by Marc Lemburg.
2000-01-12 16:28:58 +00:00
Guido van Rossum b4db1944c4 When comparing objects, always check that tp_compare is not NULL
before calling it.  This check was there when the objects were of the
same type *before* coercion, but not if they initially differed but
became the same *after* coercion.
1998-07-21 21:56:41 +00:00
Guido van Rossum cd5a5f627a When comparing objects of different types (which is done by comparing
the type names), make sure that numeric objects are considered smaller
than all other objects, by forcing their name to "".
1998-06-09 18:58:44 +00:00
Guido van Rossum 1c4f458099 In PyObject_IsTrue(), don't call function pointers that are NULL
(nb_nonzero, mp_length, sq_length).
1998-05-22 00:53:24 +00:00
Guido van Rossum 9b00dfae75 If USE_STACKCHECK is defined use PyOS_CheckStack() in the repr and str
routines. This catches a slightly different set of crashes than the
recursive-repr fix.
(Jack)
1998-04-28 16:06:54 +00:00
Guido van Rossum 565798d493 Be less naive about null characters in an object's repr(). 1998-04-21 22:25:01 +00:00
Guido van Rossum eb90946978 Some robustness checks in Py_ReprLeave() in the unlikely event someone
has messed with the dictionary or list.
1998-04-11 15:17:34 +00:00
Guido van Rossum 8661036cb8 Add implementations of Py_Repr{Enter,Leave}.
(Jeremy will hardly recognize his patch :-)
1998-04-10 22:32:46 +00:00
Guido van Rossum c3d3f9692d Add PyObject_Not(). 1998-04-09 17:53:59 +00:00
Guido van Rossum db9351643d Instead of "attribute-less object", issue an error message that
contains the type of the object and name of the attribute.
1998-01-19 22:16:36 +00:00
Guido van Rossum 242c64256c Add a new function PyNumber_CoerceEx() which works just like
PyNumber_Coerce() except that when the coercion can't be done and no
other exceptions happen, it returns 1 instead of raising an
exception.

Use this function in PyObject_Compare() to avoid raising an exception
simply because two objects with numeric behavior can't be coerced to a
common type; instead, proceed with the non-numeric default comparison.

Note that this is a somewhat questionable practice -- comparisons for
numeric objects shouldn't default to random behavior like this, but it
is required for backward compatibility.  (Case in point, it broke
comparison of kjDict objects to integers in Aaron Watters' kjbuckets
extension.)  A correct fix (for python 2.0) should involve a different
definiton of comparison altogether.
1997-11-19 16:03:17 +00:00
Guido van Rossum ea46e4d93c Fix mixup about PyErr_NoMemory() prototype. 1997-08-12 14:54:54 +00:00
Guido van Rossum e09fb55f29 Added _Py_ResetReferences(), if tracing references.
In _Py_PrintReferences(), no longer suppress once-referenced string.

Add Py_Malloc and friends and PyMem_Malloc and friends (malloc
wrappers for third parties).
1997-08-05 02:04:34 +00:00
Guido van Rossum c8b6df9004 PyObject_Compare can raise an exception now. 1997-05-23 00:06:51 +00:00
Guido van Rossum 98ff96adba Moved PyObject_{Get,Set}Attr here (from dictobject) and add PyObject_HasAttr. 1997-05-20 18:34:44 +00:00
Guido van Rossum d0c87ee6c4 Oops, another forgotten renaming: varobject -> PyVarObject. 1997-05-15 21:31:03 +00:00
Guido van Rossum c0b618a2cc Quickly renamed the last directory. 1997-05-02 03:12:38 +00:00
Guido van Rossum c6d0670f1b Intern the strings created in getattr() and setattr(). 1997-01-18 07:57:16 +00:00
Guido van Rossum da9c2710c7 Make gcc -Wall happy 1996-12-05 21:58:58 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum b7fc304109 Correct typo in setattr: return -1 for error, not NULL 1996-09-11 22:51:25 +00:00
Guido van Rossum aacdc9da75 Define reference count admin debug functions to return void. 1996-08-12 21:32:12 +00:00
Guido van Rossum d8eb1b340f Support for tp_getattro, tp_setattro (Sjoerd) 1996-08-09 20:52:03 +00:00
Guido van Rossum f5030abca8 Hacks for MS_COREDLL 1996-07-21 02:30:39 +00:00
Guido van Rossum ded690fc35 rename printrefs, getobjects to _Py_ prefix 1996-05-24 20:48:31 +00:00
Guido van Rossum 84a9032cd3 TRACE_REFS -> Py_TRACE_REFS.
Added disgusting hack to force loading of abstract.o.
1996-05-22 16:34:47 +00:00
Guido van Rossum 97ead3fb8e Hack to force loading of cobject.o 1996-01-12 01:24:09 +00:00
Sjoerd Mullender 6ec3c653da Implemented two new functions in sys:
getcounts() returns a list of counts of allocations and
		deallocations for all different object types.
	getobjects(n [, type ]) returns a list of recently allocated
		and not-yet-freed objects of the given type (all
		objects if no type given).  Only the n most recent
		(all if n==0) objects are returned.
getcounts is only available if compiled with -DCOUNT_ALLOCS,
getobjects is only available if compiled with -DTRACE_REFS.  Note that
everything must be compiled with these options!
1995-08-29 09:18:14 +00:00
Guido van Rossum 1311e3ce73 args to call_object must be tuple or NULL 1995-07-12 02:22:06 +00:00
Guido van Rossum d8953cb8d9 change in counting freed objects 1995-04-06 14:46:26 +00:00
Guido van Rossum 6f9e433ab3 fix dusty debugging macros 1995-03-29 16:57:48 +00:00
Guido van Rossum 2497eada60 make size arg signed 1995-02-10 17:00:27 +00:00
Guido van Rossum 49b11fed70 move callable() here 1995-01-26 00:38:22 +00:00
Guido van Rossum 32b582b953 fix strobject() behavior 1995-01-17 16:35:13 +00:00
Guido van Rossum 20566845c6 properly implement cmp() for class instances 1995-01-12 11:26:10 +00:00
Guido van Rossum 5524a59b09 move coerce() from bltinmodule.c to object.c and implement builtin_coerce() differently 1995-01-10 15:26:20 +00:00
Guido van Rossum 016564ab51 attribute-less object is AttributeError, not TypeError 1995-01-07 11:54:44 +00:00
Guido van Rossum 6610ad9d6b Added 1995 to copyright message.
floatobject.c: fix hash().
methodobject.c: support METH_FREENAME flag bit.
1995-01-04 19:07:38 +00:00
Guido van Rossum d7047b395e Lots of minor changes. Note for mappingobject.c: the hash table pointer
can now be NULL.
1995-01-02 19:07:15 +00:00
Guido van Rossum 9776adf565 rearranged code in debugging version of DELREF to avoid touching data
after it has been freed.
1994-09-07 14:36:45 +00:00
Guido van Rossum 1d5735e846 Merge back to main trunk 1994-08-30 08:27:36 +00:00