Commit Graph

86 Commits

Author SHA1 Message Date
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 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 152d8173a3 Fix a memory leak -- the cached values of __getattr__ etc. were never
freed.
1998-08-04 14:59:16 +00:00
Guido van Rossum d4ba73c75b Move the definition of PyMethodObject to classobject.h, so it can define
macros for more efficient access to the fields.
1998-07-10 15:46:33 +00:00
Guido van Rossum 7859f87fdb Marc-Andre Lemburg's patch to support instance methods with other
callable objects than regular Pythonm functions as their im_func.
1998-07-08 14:58:16 +00:00
Guido van Rossum 7ba30431ec Recompute the special getattr/setattr/delattr cache slots after
changing __dict__ *or* __bases__.
1998-07-08 13:34:48 +00:00
Guido van Rossum e0fdf6f1a8 Keep Microsoft's compiler happy. 1998-06-12 15:03:58 +00:00
Guido van Rossum a63eff6e6a Allow assignments to special class attributes -- with typechecks, and
not in restricted mode.

__dict__ can be set to any dictionary; the cl_getattr, cl_setattr and
cl_delattr slots are refreshed.

__name__ can be set to any string.

__bases__ can be set to to a tuple of classes, provided they are not
subclasses of the class whose attribute is being assigned.

__getattr__, __setattr__ and __delattr__ can be set to anything, or
deleted; the appropriate slot (cl_getattr, cl_setattr, cl_delattr) is
refreshed.

(Note: __name__ really doesn't need to be a special attribute, but
that would be more work.)
1998-05-29 21:37:21 +00:00
Guido van Rossum 617c1b0116 Uses PyErr_ExceptionMatches() instead of comparing PyErr_Occurred(). 1998-05-28 19:50:02 +00:00
Guido van Rossum 4180cf1649 Remove a redundant statement from halfbinop(). 1998-05-13 22:02:16 +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 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 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 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
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 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 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 c8b6df9004 PyObject_Compare can raise an exception now. 1997-05-23 00:06:51 +00:00
Guido van Rossum 0add15f6a5 removed last #ifdef SUPPORT_OBSOLETE_ACCESS bits. 1997-05-09 01:07:15 +00:00
Guido van Rossum c0b618a2cc Quickly renamed the last directory. 1997-05-02 03:12:38 +00:00
Guido van Rossum a412d24be0 Intern the various string objects created to speed up lookups. 1997-01-18 07:59:12 +00:00
Guido van Rossum cbd1e4eb5f Yet more elaborate message for exception in __del__.
Make gcc -Wall happy.
1996-12-05 21:52:32 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum 8bcf369cf9 Support passing in an empty dictionary of keywords to newinstanceobject. 1996-10-21 15:12:32 +00:00
Guido van Rossum 22a85e5308 More detailed error message about exception in __del__ 1996-09-11 22:51:57 +00:00
Guido van Rossum e5920bc4c6 Use getstringsize where available instead of strlen. 1996-08-26 14:58:03 +00:00
Guido van Rossum ad8997887b Be a bit more careful with printing a warning for a failed __del__. 1996-08-22 23:15:42 +00:00
Guido van Rossum 019f424a0a More efficient handling of "__doc__" lookup. 1996-08-21 14:54:28 +00:00
Guido van Rossum 89227eb0f5 Write warning about exception in __del__ to stderr, not stdout. 1996-08-20 19:54:29 +00:00
Guido van Rossum 0dfcf753ad Disable support for access statement 1996-08-12 22:00:53 +00:00
Guido van Rossum 2878a69922 Optimizations by Sjoerd:
- define tp_getattro, tp_setattro
- use precreated string objects for most common exceptions and method names
1996-08-09 20:53:24 +00:00
Guido van Rossum 3cb486879a Only __dict__ and __class__ are read-only instance attributes 1996-07-21 02:29:46 +00:00
Guido van Rossum 441e4ab802 new debugger symbol names 1996-05-23 22:46:51 +00:00
Guido van Rossum 6dabc98400 Added __name__ attribute to class instance method objects.
Removed im_doc attribute; __name__ and __doc__ are now handled by
special casing in instancemethodgetattr().  This saves a few bytes and
INCREF/DECREF calls per i.m. object allocation/deallocation.
1996-05-14 21:54:20 +00:00
Sjoerd Mullender 6f011d7ad5 Get ordering right for TRACE_REFS/COUNT_ALLOCS combination (otherwise
may get inc_count sanity check abort).
1995-09-18 10:49:04 +00:00
Sjoerd Mullender 740f357363 Fixed calling of __del__ method with TRACE_REFS defined. 1995-08-28 09:00:43 +00:00
Guido van Rossum ac21f6a579 class objects are read-only in restricted mode 1995-08-04 04:05:31 +00:00
Guido van Rossum a83f270a4b changes for keyword args to built-in functions and classes 1995-07-26 18:07:32 +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 e9df727176 change comparing instance methods 1995-04-06 14:46:51 +00:00
Guido van Rossum e95d92b65e removed unused vars 1995-01-26 00:39:21 +00:00
Guido van Rossum 879c581826 implement coercions involving instances properly 1995-01-10 15:24:06 +00:00
Guido van Rossum 10393b1708 add restrictions in restricted mode 1995-01-10 10:39:49 +00:00
Guido van Rossum e7d444f785 * Objects/classobject.c: added 5th (function) parameter to
instancebinop, to support things like Rational * float; added
	documentation strings to classes and methods
1995-01-07 12:35:18 +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 bb3c5f7406 fix comparison of instances without _-cmp__ 1994-11-10 22:31:02 +00:00
Sjoerd Mullender b9a6d12498 Comparison of two class instances without __cmp__ or __rcmp__ methods
was broken.
1994-10-19 15:11:52 +00:00
Guido van Rossum 03093a248d * Include/classobject.h, Objects/classobject.c, Python/ceval.c:
entirely redone operator overloading.  The rules for class
	instances are now much more relaxed than for other built-in types
	(whose coerce must still return two objects of the same type)

	* Objects/floatobject.c: add overflow check when converting float
	to int and implement truncation towards zero using ceil/float

	* Objects/longobject.c: change ValueError to OverflowError when
	converting to int

	* Objects/rangeobject.c: modernized

	* Objects/stringobject.c: use HAVE_LIMITS instead of __STDC__

	* Objects/xxobject.c: changed to use new style (not finished?)
1994-09-28 15:51:32 +00:00
Guido van Rossum 52ca98a390 Yet another version (by me) of __getattr__ etc. 1994-09-05 07:32:29 +00:00