Commit Graph

543 Commits

Author SHA1 Message Date
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 57072eb79f Implement the other easy thing: repr() of a float now uses %.17g,
while str() uses %.12g as before.
1999-12-23 19:00:28 +00:00
Fred Drake 121ee2722e long_format(): Now takes a third parameter, addL; iff true, a
trailing 'L' is appended to the representation,
                otherwise not.

                All existing call sites are modified to pass true for
                addL.

                Remove incorrect statement about external use of this
                function from elsewhere; it's static!

long_str():     Handler for the tp_str slot in the type object.
                Identical to long_repr(), but passes false as the addL
                parameter of long_format().
1999-12-23 15:41:28 +00:00
Barry Warsaw 153a27ceb2 do_strip(): Fixed cut-and-paste error; this function should check for
zero arguments (found by Marc Lemburg).
1999-12-15 02:22:52 +00:00
Barry Warsaw 226ae6ca12 Mainlining the string_methods branch. See branch revision log
messages for specific changes.
1999-10-12 19:54:53 +00:00
Guido van Rossum 2c7b8fe618 Fix PR#66. Solution: add error checking around l_divmod() calls in
long_pow().
1999-10-11 22:34:41 +00:00
Guido van Rossum 42636dc64d Fix for PR#98 (Adrian Eyre) -- in instancemethod_repr, the funcname
object is DECREFed too early.
1999-10-11 14:03:12 +00:00
Guido van Rossum e13ff2e2d6 Patch by Tim Peters fixing PR#88:
Integer division can crash under Windows.
1999-09-27 17:12:47 +00:00
Guido van Rossum 1a23c2484e Patch by Tim Peters fixing PR#89:
long(+/- infinity) returns nonsense.
1999-09-27 17:11:52 +00:00
Guido van Rossum ff7e83d606 Patch by Mark Hammond to avoid certain header files on Windows/CE. 1999-08-27 20:39:37 +00:00
Fred Drake 4574f23115 PyBuffer_New(): Raise ValueError if size is negative (the other
constructors didn't miss this).

		 Raise MemoryError if malloc() fails, instead of just
		 returning NULL.
1999-08-04 13:08:19 +00:00
Guido van Rossum 0eb55ac912 Mark Favas was quick to note that the last checkin divides by zero
when n == 0...  So divide by a->ob_size instead which was already
tested for 0.
1999-07-13 05:41:12 +00:00
Guido van Rossum 5bc51f2f27 Appropriate overflow checks so that things like sys.maxint*(1,) can't
dump core.
1999-07-12 23:06:58 +00:00
Guido van Rossum fa71701d46 When deallocating a list, DECREF the items from the end back to the start. 1999-06-09 15:19:34 +00:00
Guido van Rossum 98c9eba945 Fix bug discovered by John W. Shipman -- when the width of a format
specifier came from an int expression instead of a constant in the
format, a negative width was truncated to zero instead of taken to
mean the same as that negative constant plugged into the format.  E.g.
"(%*s)" % (-5, "foo") yielded "(foo)" while "(%-5s)" yields "(foo  )".
Now both yield the latter -- like sprintf() in C.
1999-06-07 15:12:32 +00:00
Guido van Rossum 9263e78ff2 Tim Peters writes:
1. Fixes float divmod so that the quotient it returns is always an integral
value.

2. Fixes float % and float divmod so that the remainder always gets the
right sign (the current code uses a "are the signs different?" test that
doesn't work half the time <wink> when the product of the divisor and the
remainder underflows to 0).
1999-05-06 14:26:34 +00:00
Guido van Rossum 9bcd1d7931 Improve text of some error messages, as suggested by Sean Reifschneider. 1999-04-19 17:44:39 +00:00
Guido van Rossum ff1ccbfc21 casts for picky compilers. 1999-04-10 15:48:23 +00:00
Guido van Rossum 2bc137909d Vladimir Marangozov contributed updated comments. 1999-03-24 19:06:42 +00:00
Guido van Rossum cd037e7bed Folded long lines. 1999-03-24 19:05:31 +00:00
Guido van Rossum d7b5fb858c Fix a problem with Vladimir's PyFloat_Fini code: clear the free list; if
a block cannot be freed, add its free items back to the free list.
This is necessary to avoid leaking when Python is reinitialized later.
1999-03-19 20:59:40 +00:00
Guido van Rossum 51288bce48 Fix a problem with Vladimir's PyInt_Fini code: clear the free list; if
a block cannot be freed, add its free items back to the free list, and
add its valid ints back to the small_ints array if they are in range.
This is necessary to avoid leaking when Python is reinitialized later.
1999-03-19 20:30:39 +00:00
Guido van Rossum 49ded3ec00 Added check for negative offset for PyBuffer_FromObject and check for
negative size for PyBuffer_FromMemory.  Greg Stein.
1999-03-19 19:04:25 +00:00
Guido van Rossum 3fce883922 Vladimir has restructured his code somewhat so that the blocks are now
represented by an explicit structure.  (There are still too many casts
in the code, but that may be unavoidable.)

Also added code so that with -vv it is very chatty about what it does.
1999-03-12 19:43:17 +00:00
Guido van Rossum f61bbc8182 OK, try again. Vladimir gave me a fix for the alignment bus error,
so here's his patch again.  This time it works (at least on Solaris,
Linux and Irix).
1999-03-12 00:12:21 +00:00
Guido van Rossum a060fb2598 Alas, Vladimir's patch caused a bus error (probably double
alignment?), and I didn't test it.  Withdrawing it for now.
1999-03-11 01:47:00 +00:00
Guido van Rossum 881928f7ab Patch by Vladimir Marangoz to allow freeing of the allocated blocks of
floats on finalization.
1999-03-10 22:55:47 +00:00
Guido van Rossum da084edd38 Patch by Vladimir Marangoz to allow freeing of the allocated blocks of
integers on finalization.
1999-03-10 22:55:24 +00:00
Guido van Rossum 98cc19fac6 Patch by Chris Petrilli to display the origin of a module in its
repr() -- either "(builtin)" or "from '<filename>'".
1999-02-15 14:47:16 +00:00
Guido van Rossum 00d225ea6d Correct typo (Py_MethodDef doesn't exist). Reported by Uwe Zessin. 1999-01-29 14:39:12 +00:00
Barry Warsaw b5cebfe164 PyLong_FromString(): Nailed a small memory leak. In the str==start
test, we forgot that z is still pointing to a real live object.
DECREF() it before returning.
1999-01-27 17:48:27 +00:00
Guido van Rossum 3bbef60990 Ai! complex_nonzero() has && which should be ||, else decidedly
non-zero things like 5j and complex(1,0) are considered to be
zero/false.  Tim Peters.
1999-01-25 19:42:19 +00:00
Guido van Rossum 3aa23fdd47 Jim Ahlstrom patch: cutoff should be a long for machines with 16-bit
ints.  (In theory, other variables should be widened to long as well,
but this won't ever be needed, since the len of a list is still an
int.)
1999-01-14 19:01:53 +00:00
Guido van Rossum 3c25904a98 Jim Ahlstrom patch: BIGCHUNK is too large for 16-bit int. 1999-01-14 19:00:14 +00:00
Guido van Rossum 031d0e5feb Patch by Charles Waldman -- remove unneeded and even harmful test for
float to the negative power (which is already and better done in
floatobject.c.)
1999-01-10 16:56:58 +00:00
Guido van Rossum 5dadf7e976 Use 'xrange', not 'range', in error messages. Reported by Nathan Sullivan. 1999-01-09 21:40:35 +00:00
Guido van Rossum 41498435ba Need to include <sys/types.h> for off_t. 1999-01-07 22:09:51 +00:00
Guido van Rossum 3c9fe0cce3 Changes for long file support by Steve Clift.
(This also redoes my previous patch, but better.)
1999-01-06 18:51:17 +00:00
Guido van Rossum cdd9ae00ba Changes for long file support by Steve Clift.
(Really: moved a bunch of defs to longobject.h.)
1999-01-06 18:50:37 +00:00
Guido van Rossum 88303194a5 Fix two places (seek and truncate) where a cascade of PyArg_Parse
calls was used instead of a single PyArg_ParseTuple call with an
optional argument.
1999-01-04 17:22:18 +00:00
Guido van Rossum cada2938f7 As noted by Per Cederqvist, new_buffersize() sometimes returns the
buffer increment, and sometimes the new buffer size.  Make it do what
its name says, and fix the one place where this matters to the caller.

Also add a comment explaining why we call lseek() and then ftell().
1998-12-11 20:44:56 +00:00
Guido van Rossum 68055ce6fe When tracing references, reset the type and size of tuples allocated
from the fast free list -- the type (at least) is reset by
_Py_Dealloc().
1998-12-11 14:56:38 +00:00
Guido van Rossum f5046d1aea Remove prototype for PyOS_strtol -- Chris Herborth. 1998-12-10 16:54:48 +00:00
Guido van Rossum 13fdf5e917 When comparing bound methods, use identity test on the objects,
not equality test.
1998-12-04 18:52:55 +00:00
Guido van Rossum f05fc716d1 Remove dead code discovered by Vladimir Marangozov. 1998-11-16 22:46:30 +00:00
Guido van Rossum 017f7780a8 Make tuples less hungry -- an extra item was allocated but never used.
Tip by Vladimir Marangozov.
1998-11-16 18:56:03 +00:00
Guido van Rossum f61618c98e A Py_DECREF(f) is missing in PyFrame_New for the error case when
the `builtins' initialization fails.  Vladimir Marangozov.
1998-10-19 14:20:20 +00:00
Guido van Rossum 2f3667a7b9 Replace fprintf(stderr, ...) with PySys_WriteStderr(...). 1998-10-12 18:23:55 +00:00
Barry Warsaw dedf6d6804 listextend(): New method which implements L.extend(L2). 1998-10-09 16:37:25 +00:00
Guido van Rossum 3886026bed Remove unreachable code. (Sjoerd) 1998-10-09 13:27:19 +00:00