Commit Graph

425 Commits

Author SHA1 Message Date
Guido van Rossum f7d590c93d This was the reason a numeric array to a real power was not working. 1998-04-03 23:38:59 +00:00
Guido van Rossum 240c35aac0 Subtle fix in the read() code which could cause a read broken up in
several pieces to fail...
1998-03-18 17:59:20 +00:00
Guido van Rossum f8b4de02a4 When we have no setvbuf(), make the file totally unbuffered using
setbuf() if a buffer size of 0 or 1 byte is requested.
1998-03-06 15:32:40 +00:00
Guido van Rossum dcb5e7f389 Of course, I shouldn't have used lseek() to find out the file's
position in new_buffersize(); the correct function to use is ftell().
Thanks to Ben Jackson.
1998-03-03 22:36:10 +00:00
Guido van Rossum 044b9dc1d7 Add back some safeguards on the index elements that were lost in the
last patch.  Dave Ascher found a case that dumps core without these:

def myComparison(x,y):
    return cmp(x%3,y%7)

z = range(12)
z.sort(myComparison)
1998-02-25 17:50:03 +00:00
Guido van Rossum f1dc0615e9 Add internal routine _PyModule_Clear(), which does approximately what
clear_carefully() used to do in import.c.  Differences: leave only
__builtins__ alone in the 2nd pass; and don't clear the dictionary (on
the theory that as long as there are references left to the
dictionary, those might be destructors that might expect __builtins__
to be alive when they run; and __builtins__ can't normally be part of
a cycle).
1998-02-19 20:51:52 +00:00
Guido van Rossum bde6ff7984 Vladimir Marangozov' performance hack: copy f_builtins from ancestor
if the globals are the same.

Also, when creating a dummy builtins dictionary, add "None" to it,
just to be kind.
1998-02-19 20:48:26 +00:00
Guido van Rossum 3da3fcef96 Check ferror(), not errno, for fread() error. 1998-02-19 20:46:48 +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 24e62e2c7c Modified quicksort by Raymund Galvin, after studying the GNU libg++
quicksort.  This should be much faster if there are lots of
duplicates, and otherwise at least as good.
1997-12-10 15:14:24 +00:00
Guido van Rossum b7f1afe4a8 Change the default repr() and str() of class instance objects to look
like <modulename.classname instance at ...> (to match the repr() of
class objects.
1997-12-03 00:06:02 +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 3931df9250 Undo another glitch of the automatic not-so-Grand Renaming; some local
variables called 'coerce' were accidentally renamed to
'PyNumber_Coerce'.  Rename them back to coercefunc.
1997-11-18 19:23:07 +00:00
Guido van Rossum f51815426e Fix problem discovered by Barry: if you hit ^C to
sys.stdin.readline(), you get a fatal error (no current thread).  This
is because there was a call to PyErr_CheckSignals() while there was no
current thread.  I wonder how many more of these we find...  I bnetter
go hunting for PyErr_CheckSignals() now...
1997-11-07 19:20:34 +00:00
Guido van Rossum 6345ac6d61 Add cast to realloc/malloc call to shut up AIX compiler. (Vladimir Marangozov) 1997-10-31 20:32:13 +00:00
Guido van Rossum 3c03fa87b6 Hack suggested by Matthias Klose to pull in all relevant entry points
in libmath.a so they are available to mathmodule.so (in case it is
shared).  While this still gets triggered on Solaris 2.x, this appears
to be harmless there.
1997-10-31 17:00:30 +00:00
Guido van Rossum 1f84449fd8 New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
PyCObject_GetDesc().
1997-10-21 19:48:35 +00:00
Guido van Rossum 4a2a621907 Write a str() function for class objects that returns
"modulename.classname" instead of returning the same as repr().
1997-10-20 23:26:11 +00:00
Guido van Rossum 6fcfa72c63 Correct Barry's fix -- take care of {}.get(0). 1997-10-20 20:10:00 +00:00
Barry Warsaw 320ac331d1 dict_get(): Fixed a couple of stupid mistakes which caused crashes.
Also got rid of some unnecessary code.
1997-10-20 17:26:25 +00:00
Guido van Rossum 04d73c495e Check that all base classes are indeed class objects, rather than
expecting the caller to do so.
1997-10-07 14:54:11 +00:00
Barry Warsaw c38c5da5d0 dict_get(): New method for item access with different semantics than
__getitem__().  This method never raises an exception; if the key is
not in the dictionary, the second (optional) argument is returned.  If
the second argument is not provided and the key is missing, None is
returned.

mapp_methods: added "get" method.
1997-10-06 17:49:20 +00:00
Guido van Rossum 4f3bf1e383 Don't intern the key string for getitem and delitem. 1997-09-29 23:31:11 +00:00
Guido van Rossum 7cc56eb524 When creating a class, set its __module__ attribute to the module
whose name is in the current globals' __name__ variable.  If __name__
is not set, ignore this.
1997-09-12 20:04:46 +00:00
Guido van Rossum 045e688f6f Patch submitted by Brad Howes (with one bug fixed by me): allow
arbitrary nested parens in a %(...)X style format.
#Also folded two lines and added more detail to the error message for
#unsupported format character.
1997-09-08 18:30:11 +00:00
Guido van Rossum b2173c3146 Allow assignments to instance.__dict__ and instance.__class__. The
former lets you give an instance a set of new instance vars.  The
latter lets you give it a new class.  Both are typechecked and
disallowed in restricted mode.

For classes, the check for read-only special attributes is tightened
so that only assignments to __dict__, __bases__, __name__,
__getattr__, __setattr__, and __delattr__ (these could be made to work
as well, but I don't know if that's useful -- let's see first whether
mucking with instances will help).
1997-08-25 21:23:56 +00:00
Guido van Rossum a27d112213 Rename roundup() to roundupsize(), as there's a macro roundup() in the
sys/types.h header on many systems that may get pulled in (through
WANT_SIGFPE_HANDLER which pulls in signal.h).
1997-08-25 18:36:23 +00:00
Guido van Rossum 36f8e2d1db Use lseek instead of ftell; compensate by adding BUFSIZE 1997-08-21 02:31:25 +00:00
Guido van Rossum fd7a0b871f Made lookdict nearly twice as fast, resulting in a 5% overall
improvement of pystone.  Vladimir Marangozov.
1997-08-18 21:52:47 +00:00
Guido van Rossum 787bdd37a0 PyTuple_SetItem should require that the tuple's refcnt is one! 1997-08-17 16:25:45 +00:00
Guido van Rossum ea46e4d93c Fix mixup about PyErr_NoMemory() prototype. 1997-08-12 14:54:54 +00:00
Guido van Rossum 83f9ad8399 Fix bug in comparing function objects detected by Sjoerd:
SystemError: bad argument to internal function

caused by comparing NULL pointer default args.
1997-08-05 16:51:05 +00:00
Guido van Rossum fbbd57e4ca Added _Fini() routines to free up some memory 1997-08-05 02:16:08 +00:00
Guido van Rossum 971a7aaeac Change the Fini function to only remove otherwise unreferenced strings
from the interned table.  There are references in hard-to-find static
variables all over the interpreter, and it's not worth trying to get
rid of all those; but "uninterning" isn't fair either and may cause
subtle failures later -- so we have to keep them in the interned
table.

Also get rid of no-longer-needed insert of None in interned dict.
1997-08-05 02:15:12 +00:00
Guido van Rossum 1f39c5c666 Added separate free list for cfunction (builtin method) objects, for a
few percent speed up.  Also add PyCFunction_Fini() to discard it.
1997-08-05 02:11:41 +00:00
Guido van Rossum 404b95d9ba Provide a dummy empty directory as f_builtins instead of failing, when
no valid directory is passed in.  This prevents __del__ to fail when
invoked after __builtins__ has already been discarded.

Also add PyFrame_Fini() to discard the cache of frames.
1997-08-05 02:09:46 +00:00
Guido van Rossum a0d349f46a Added separate free list for instance method objects, for a few
percent speed up.  Also add PyMethod_Fini() to discard it.
1997-08-05 02:06:53 +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 eb46d67ce5 Avoid function calls to access the current thread state and builtins
-- the thread state is passed in as an argument and the builtins are a
member thereof.
1997-08-02 02:59:08 +00:00
Guido van Rossum 8cf0476474 Added internal routine PyString_Fini() which deletes all interned
strings.  For use in Py_Finalize() only.
1997-08-02 02:57:45 +00:00
Guido van Rossum f6ca6aa869 New build procedure. 1997-07-19 19:39:57 +00:00
Guido van Rossum 5d8123f34a Reordered list of methods to hopefully put the most frequently used
ones near the front.
1997-07-13 03:58:01 +00:00
Guido van Rossum 74ba24758e Reordered list of methods to hopefully put the most frequently used
ones near the front.

Also added a missing "return -1" to PyFile_WriteString.
1997-07-13 03:56:50 +00:00
Guido van Rossum 71160aaffe Use #include "mymath.h" instead of declaring fabs() explicitly.
This should solve a weird problem on the Mac for Jack.
1997-06-03 18:03:18 +00:00
Guido van Rossum a8d5131d57 Renamed dict.absorb() (too spungy) to dict.update(). 1997-06-02 17:13:37 +00:00
Guido van Rossum 80c2a1674e American spelling in doc string. 1997-06-02 14:43:07 +00:00
Guido van Rossum e3f5b9c8d1 Added dict.absorb() and dict.copy(). 1997-05-28 19:15:28 +00:00
Guido van Rossum c8b6df9004 PyObject_Compare can raise an exception now. 1997-05-23 00:06:51 +00:00
Guido van Rossum 5b2121b25f PyObject_Compare can now return an error. Unfortunately, there are a
few places where we don't know how to test for them without losing
speed; don't know yet how to handle that.
1997-05-23 00:01:41 +00:00
Guido van Rossum 27a60b147c PyFile_WriteString now returns an error indicator instead of calling
PyErr_Clear().
1997-05-22 22:25:11 +00:00