Commit Graph

81 Commits

Author SHA1 Message Date
Fred Drake b60654bc15 The return value from PyObject_ClearWeakRefs() is no longer meaningful,
so make it void.
2001-02-26 18:56:37 +00:00
Fred Drake 033f31270c Use a type flag to determine the applicability of the tp_weaklistoffset
field.  This should avoid binary incompatibility problems with older modules
that have not been recompiled.
2001-02-02 18:17:30 +00:00
Jeremy Hylton 483638c9a8 Undo recent change that banned using import to bind a global, as per
discussion on python-dev.  'from mod import *' is still banned except
at the module level.

Fix value for special NOOPT entry in symtable.  Initialze to 0 instead
of None, so that later uses of PyInt_AS_LONG() are valid.  (Bug
reported by Donn Cave.)

replace local REPR macros with PyObject_REPR in object.h
2001-02-01 20:20:45 +00:00
Fred Drake 41deb1efc2 PEP 205, Weak References -- initial checkin. 2001-02-01 05:27:45 +00:00
Guido van Rossum bacca54b59 Add a flag to indicate the presence of the tp_richcompare field, and
add it to the default flags.
2001-01-24 22:13:48 +00:00
Barry Warsaw 10418eb80f PyObject_Dump() -> _PyObject_Dump() 2001-01-24 04:16:59 +00:00
Barry Warsaw 6a25e210c9 Add prototype for PyObject_Dump(). 2001-01-23 16:33:56 +00:00
Guido van Rossum 722642902e Get rid of the declaration for _PyCompareState_Key. 2001-01-17 21:28:08 +00:00
Marc-André Lemburg ad7c98e264 This patch adds a new builtin unistr() which behaves like str()
except that it always returns Unicode objects.

A new C API PyObject_Unicode() is also provided.

This closes patch #101664.

Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-17 17:09:53 +00:00
Guido van Rossum 5f284ce68e Introduction to rich comparisons:
- Removed the nb_add slot from the PyNumberMethods struct.

- Renamed Py_TPFLAGS_NEWSTYLENUMBER to Py_TPFLAGS_CHECKTYPES.

- Added typedef richcmpfunc.

- Added tp_richcompare slot to PyTypeObject (replacing spare tp_xxx7).

- Added APIs PyObject_RichCompare() and PyObject_RichCompareBool().

- Added rich comparison operators Py_LT through Py_GE.
2001-01-17 15:20:39 +00:00
Neil Schemenauer a7ed694542 - Add nb_cmp slot for new style nubmers.
- Define type flag for new style numbers.
- Add Py_NotImplemented.
2001-01-04 01:31:50 +00:00
Tim Peters 4826a894c5 Close SF bug 110826: a complaint about the way Python #define'd NULL.
It's hard to sort out what the bug was, exactly.  So, Big Hammer:

1. Python shouldn't be in the business of #define'ing NULL, period.
2. Users of the Python C API shouldn't be in the business of not including
   Python.h, period.

Hence:

1. Removed all #define's of NULL in Python source code (pyport.h and
   object.h).
2. Since we're *relying* on stdio.h defining NULL, put an #error in
   Python.h after its #include of stdio.h if NULL isn't defined then.
2000-09-10 01:02:41 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Thomas Wouters dd8dbdb717 The real suport for augmented assignment: new opcodes, new PyNumber and
PySequence methods and functions, new tokens.
2000-08-24 20:09:45 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Fred Drake bd03bfce45 Remove legacy use of __SC__; no longer needed now that ANSI source is
the standard for Python implementation.
2000-07-09 14:22:08 +00:00
Greg Stein a90b23c571 One of the new prototypes was missing the "void" args. 2000-07-08 00:46:19 +00:00
Tim Peters 9ace6bc7ef Got RID of redundant coercions in longobject.c (as spotted by Greg
Stein -- thanks!).  Incidentally removed all the Py_PROTO macros
from object.h, as they prevented my editor from magically finding
the definitions of the "coercion", "cmpfunc" and "reprfunc"
typedefs that were being redundantly applied in longobject.c.
2000-07-08 00:32:04 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Fred Drake 13634cf7a4 This patch addresses two main issues: (1) There exist some non-fatal
errors in some of the hash algorithms. For exmaple, in float_hash and
complex_hash a certain part of the value is not included in the hash
calculation. See Tim's, Guido's, and my discussion of this on
python-dev in May under the title "fix float_hash and complex_hash for
64-bit *nix"

(2) The hash algorithms that use pointers (e.g. func_hash, code_hash)
are universally not correct on Win64 (they assume that sizeof(long) ==
sizeof(void*))

As well, this patch significantly cleans up the hash code. It adds the
two function _Py_HashDouble and _PyHash_VoidPtr that the various
hashing routine are changed to use.

These help maintain the hash function invariant: (a==b) =>
(hash(a)==hash(b))) I have added Lib/test/test_hash.py and
Lib/test/output/test_hash to test this for some cases.
2000-06-29 19:17:04 +00:00
Jeremy Hylton d08b4c4524 part 2 of Neil Schemenauer's GC patches:
This patch modifies the type structures of objects that
participate in GC.  The object's tp_basicsize is increased when
GC is enabled.  GC information is prefixed to the object to
maintain binary compatibility.  GC objects also define the
tp_flag Py_TPFLAGS_GC.
2000-06-23 19:37:02 +00:00
Jeremy Hylton 8caad49c30 Round 1 of Neil Schemenauer's GC patches:
This patch adds the type methods traverse and clear necessary for GC
implementation.
2000-06-23 14:18:11 +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
Fred Drake 0e12bcd243 Updated comment: in PyTypeObject:
/* More standard operations (at end for binary compatibility) */

should now be:

	/* More standard operations (here for binary compatibility) */

since they're no longer at the end!
2000-03-21 16:14:47 +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 c6e87a2925 Got rid of silly "123456789-..." lines in comments. 2000-03-01 15:06:53 +00:00
Guido van Rossum cecb27a49c Patch by Mozhe Zadka, for __contains__ (overloading 'in'). This adds
a new proc type (objobjproc), a new slot sq_contains to
PySequenceMethods, and a new flag Py_TPFLAGS_HAVE_SEQUENCE_IN to
Py_TPFLAGS_DEFAULT.  More to follow.
2000-02-28 15:00:40 +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 43466ec7b0 Add DL_IMPORT(returntype) for all officially exported functions. 1998-12-04 18:48:25 +00:00
Guido van Rossum 36eef3c173 Changes by Greg Stein (code) and GvR (design).
Add a new member to the PyBufferProcs struct, bf_getcharbuffer.  For
backward compatibility, this member should only be used (this includes
testing for NULL!) when the flag Py_TPFLAGS_HAVE_GETCHARBUFFER is set
in the type structure, below.  Note that if its flag is not set, we
may be looking at an extension module compiled for 1.5.1, which will
have garbage at the bf_getcharbuffer member (because the struct wasn't
as long then).  If the flag is one, the pointer may still be NULL.
The function found at this member is used in a similar manner as
bf_getreadbuffer, but it is known to point to 8-bit character data.
(See discussion in getargs.c checked in later.)

As a general feature for extending the type structure and the various
structures that (may) hang off it in a backwards compatible way, we
rename the tp_xxx4 "spare" slot to tp_flags.  In 1.5.1 and before,
this slot was always zero.  In 1.5.1, it may contain various flags
indicating extra fields that weren't present in 1.5.1.  The only flag
defined so far is for the bf_getcharbuffer member of the PyBufferProcs
struct.

Note that the new spares (tp_xxx5 - tp_xxx8), once they become used,
should also be protected by a flag (or flags) in tp_flags.
1998-10-08 02:10:56 +00:00
Guido van Rossum a9c2d7a87c Add new spares to the end of the type object struct. 1998-04-23 19:16:44 +00:00
Guido van Rossum 26d4ac30be Add prototypes for Py_Repr{Enter,Leave}.
(Jeremy will hardly recognize his patch :-)
1998-04-10 22:32:24 +00:00
Guido van Rossum c3d3f9692d Add PyObject_Not(). 1998-04-09 17:53:59 +00:00
Guido van Rossum 127b8dd8d4 Add declaration for PyNumber_CoerceEx(). 1997-11-19 16:04:54 +00:00
Guido van Rossum 114c1eabbb #Added prototype for PyObject_HasAttr() -- must've been an oversight. 1997-09-06 18:44:59 +00:00
Fred Drake 49bb0e32a0 Fix in trailing comment: PyDict_SetItemString() does *not* consume a reference
count, PyList_SetItem() does.  Very confusing!
1997-09-05 17:53:53 +00:00
Guido van Rossum 1d529d1ecd Add a cast to the call to _Py_Dealloc in the expanded version of
Py_DECREF, to reduce the warnings when compiling with reference count
debugging on.  (There are still warnings for each call to
_Py_NewReference -- too bad.)
1997-08-05 02:30:44 +00:00
Guido van Rossum d0c87ee6c4 Oops, another forgotten renaming: varobject -> PyVarObject. 1997-05-15 21:31:03 +00:00
Guido van Rossum fdf95dd525 Checkin of Jack's buffer mods.
Not really checked, but didn't fail any tests either...
1997-05-05 22:15:02 +00:00
Guido van Rossum 408027ea46 Rename DEBUG macro to Py_DEBUG 1996-12-30 16:17:54 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum d86b38003d Added extern declarations for reference count admin debug functions. 1996-08-12 21:31:32 +00:00
Guido van Rossum 0693dd232e Added tp_getattro, tp_setattro (Sjoerd) 1996-08-09 20:48:52 +00:00
Guido van Rossum e1cd6c175b don't use NDEBUG 1996-05-24 20:43:12 +00:00
Guido van Rossum 60be1db9a9 Added some visual enhancements of debugging ifdefs.
Added PyNumber_Coerce decl.
1996-05-22 16:33:22 +00:00
Guido van Rossum 454674d5db add forgotten PyObject_SetAttrString 1995-07-26 17:53:29 +00:00
Guido van Rossum 884afd654a keyword arguments and faster function calls 1995-07-18 14:21:06 +00:00
Sjoerd Mullender 107c747009 DL_IMPORT needs an argument. 1995-04-25 11:53:24 +00:00