Commit Graph

105 Commits

Author SHA1 Message Date
Fred Drake d5fadf75e4 Rationalize use of limits.h, moving the inclusion to Python.h.
Add definitions of INT_MAX and LONG_MAX to pyport.h.
Remove includes of limits.h and conditional definitions of INT_MAX
and LONG_MAX elsewhere.

This closes SourceForge patch #101659 and bug #115323.
2000-09-26 05:46:01 +00:00
Guido van Rossum 1e3c8ccb9b As suggested by Toby Dickenson, setting ob_type to NULL in
_Py_Dealloc(), is a bad idea (and always was!).  So let's drop it.
2000-09-21 16:25:33 +00:00
Marc-André Lemburg e44e507b0e PyObject_SetAttr() and PyObject_GetAttr() now also accept Unicode
objects for the attribute name. Unicode objects are converted to
a string using the default encoding before trying the lookup.

Note that previously it was allowed to pass arbitrary objects as
attribute name in case the tp_getattro/setattro slots were defined.
This patch fixes this by applying an explicit string check first:
all uses of these slots expect string objects and do not check
for the type resulting in a core dump. The tp_getattro/setattro
are still useful as optimization for lookups using interned
string objects though.

This patch fixes bug #113829.
2000-09-18 16:20:57 +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
Guido van Rossum 9c0a99ec1a PyOS_CheckStack() returns 1 when failing, not -1. 2000-08-30 15:53:50 +00:00
Jack Jansen d49cbe1060 Added PyOS_CheckStack call to PyObject_Compare
Lowered the recursion limit on compares to 60 (one recursion depth can
take a whopping 2K of stack space when running test_b1!)
2000-08-22 21:52:51 +00:00
Barry Warsaw 9d23a4eb03 make_pair(): When comparing the pointers, they must be cast to integer
types (i.e. Py_uintptr_t, our spelling of C9X's uintptr_t).  ANSI
specifies that pointer compares other than == and != to non-related
structures are undefined.  This quiets an Insure portability warning.
2000-08-18 05:01:19 +00:00
Andrew M. Kuchling 1582a3ab98 Updated comment 2000-08-16 12:27:23 +00:00
Tim Peters 39dce29365 Fix for http://sourceforge.net/bugs/?func=detailbug&bug_id=111866&group_id=5470.
This was a misleading bug -- the true "bug" was that hash(x) gave an error
return when x is an infinity.  Fixed that.  Added new Py_IS_INFINITY macro to
pyport.h.  Rearranged code to reduce growing duplication in hashing of float and
complex numbers, pushing Trent's earlier stab at that to a logical conclusion.
Fixed exceedingly rare bug where hashing of floats could return -1 even if there
wasn't an error (didn't waste time trying to construct a test case, it was simply
obvious from the code that it *could* happen).  Improved complex hash so that
hash(complex(x, y)) doesn't systematically equal hash(complex(y, x)) anymore.
2000-08-15 03:34:48 +00:00
Vladimir Marangozov 1d3e239f08 Fix missing decrements of the recursive counter in PyObject_Compare().
Closes Patch #101065.
2000-08-11 00:14:26 +00:00
Moshe Zadka cf703f04ad Removing warnings found by gcc -Wall 2000-08-04 15:36:13 +00:00
Peter Schneider-Kamp 7e01890986 merge Include/my*.h into Include/pyport.h
marked my*.h as obsolete
2000-07-31 15:28:04 +00:00
Thomas Wouters 334fb8985b Use 'void' directly instead of the ANY #define, now that all code is ANSI C.
Leave the actual #define in for API compatibility.
2000-07-25 12:56:38 +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
Vladimir Marangozov 8dc19f672b Propagate the current exception in get_inprogress_dict() -- it doesn't
need to be cleared.
2000-07-12 23:39:38 +00:00
Jeremy Hylton 6253f83b0a change abstract size functions PySequence_Size &c.
add macros for backwards compatibility with C source
2000-07-12 12:56:19 +00:00
Jack Jansen 28fc880e9a Include macglue.h on the macintosh, so function prototypes are in scope. 2000-07-11 21:47:20 +00:00
Fred Drake 100814dc44 ANSI-fication of the sources. 2000-07-09 15:48:49 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Fredrik Lundh 2a1e060619 - changed __repr__ to use "unicode escape" encoding for unicode
strings, instead of the default encoding.
  (see "minidom" thread for discussion, and also patch #100706)
2000-07-08 17:43:32 +00:00
Skip Montanaro 4cbc9f7650 delete unused local variable from _PyTrash_deposit_object 2000-07-08 12:06:36 +00:00
Marc-André Lemburg 891bc65486 If auto-conversion fails, the Unicode codecs will return NULL.
This is now checked and the error passed on to the caller.
2000-07-03 09:57:53 +00:00
Fredrik Lundh efecc7d05b changed repr and str to always convert unicode strings
to 8-bit strings, using the default encoding.
2000-07-01 14:31:09 +00:00
Guido van Rossum 4cc6ac7b87 Neil Schemenauer: small fixes for GC 2000-07-01 01:00:38 +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 a44d353e2b Trent Mick <trentm@activestate.com>:
The common technique for printing out a pointer has been to cast to a long
and use the "%lx" printf modifier. This is incorrect on Win64 where casting
to a long truncates the pointer. The "%p" formatter should be used instead.

The problem as stated by Tim:
> Unfortunately, the C committee refused to define what %p conversion "looks
> like" -- they explicitly allowed it to be implementation-defined. Older
> versions of Microsoft C even stuck a colon in the middle of the address (in
> the days of segment+offset addressing)!

The result is that the hex value of a pointer will maybe/maybe not have a 0x
prepended to it.


Notes on the patch:

There are two main classes of changes:
- in the various repr() functions that print out pointers
- debugging printf's in the various thread_*.h files (these are why the
patch is large)


Closes SourceForge patch #100505.
2000-06-30 15:01:00 +00:00
Jeremy Hylton c5007aa5c3 final patches from Neil Schemenauer for garbage collection 2000-06-30 05:02:53 +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
Guido van Rossum ad89bbcd88 Trent Mick: change a few casts for Win64 compatibility. 2000-06-28 21:57:18 +00:00
Jeremy Hylton 99a8f90874 raise TypeError when PyObject_Get/SetAttr called with non-string name 2000-06-23 14:36:32 +00:00
Jeremy Hylton a251ea0680 the PyDict_SetItem does not borrow a reference, so we need to decref
reported by Mark Hammon
2000-06-09 16:20:39 +00:00
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