- 30 Aug, 2001 3 commits
-
-
Guido van Rossum authored
__dict__ slot for string subtypes. subtype_dealloc(): properly use _PyObject_GetDictPtr() to get the (potentially negative) dict offset. Don't copy things into local variables that are used only once. type_new(): properly calculate a negative dict offset when tp_itemsize is nonzero. The __dict__ attribute, if present, is now a calculated attribute rather than a structure member.
-
Guido van Rossum authored
If tp_itemsize of the basetype is nonzero, only allow empty __slots__ (declaring that no __dict__ should be added), and don't add a weakref offset.
-
Guido van Rossum authored
-
- 29 Aug, 2001 2 commits
-
-
Neil Schemenauer authored
-
Guido van Rossum authored
In particular, the second argument can now be a subclass of the first as well (normally it must be an instance though).
-
- 28 Aug, 2001 3 commits
-
-
Guido van Rossum authored
Dunno why I didn't catch this before.
-
Guido van Rossum authored
directly.
-
Guido van Rossum authored
don't use getattr, but only look in the dict of the type and base types. This prevents picking up all sorts of weird stuff, including things defined by the metaclass when the object is a class (type). For this purpose, a helper function lookup_method() was added. One or two other places also use this.
-
- 24 Aug, 2001 3 commits
-
-
Barry Warsaw authored
into a hardcoded char* buffer. Closes patch #454743.
-
Guido van Rossum authored
super(type) -> unbound super object super(type, obj) -> bound super object; requires isinstance(obj, type) Typical use to call a cooperative superclass method: class C(B): def meth(self, arg): super(C, self).meth(arg);
-
Guido van Rossum authored
Thomas Hellor on python-dev). slot_tp_descr_set(): if value is NULL, call __del__ instead of __set__.
-
- 22 Aug, 2001 1 commit
-
-
Barry Warsaw authored
level to 2.2a2+
-
- 17 Aug, 2001 4 commits
-
-
Guido van Rossum authored
interpretation of negative indices, since neither the sq_*item slots nor the slot_ wrappers do this. (Slices are a different story, there the size wrapping is done too early.)
-
Guido van Rossum authored
Classes that don't use __slots__ have a __weakref__ member added in the same way as __dict__ is added (i.e. only if the base didn't already have one). Classes using __slots__ can enable weak referenceability by adding '__weakref__' to the __slots__ list. Renamed the __weaklistoffset__ class member to __weakrefoffset__ -- it's not always a list, it seems. (Is tp_weaklistoffset a historical misnomer, or do I misunderstand this?)
-
Guido van Rossum authored
the class dict). Anything but a nonnegative int in either place is *ignored* (before, a non-Boolean was an error). The default is still static -- in a comparative test, Jeremy's Tools/compiler package ran twice as slow (compiling itself) using dynamic as the default. (The static version, which requires a few tweaks to avoid modifying class variables, runs at about the same speed as the classic version.) slot_tp_descr_get(): this also needed fallback behavior. slot_tp_getattro(): remove a debug fprintf() call.
-
Guido van Rossum authored
the metatype passed in as an argument. This prevents infinite recursion when a metatype written in Python calls type.__new__() as a "super" call. Also tweaked some comments.
-
- 16 Aug, 2001 4 commits
-
-
Guido van Rossum authored
type_repr() for when to show or not to show it).
-
Martin v. Löwis authored
-
Guido van Rossum authored
- type_module(), type_name(): if tp_name contains one or more period, the part before the last period is __module__, the part after that is __name__. Otherwise, for non-heap types, __module__ is "__builtin__". For heap types, __module__ is looked up in tp_defined. - type_new(): heap types have their __module__ set from globals().__name__; a pre-existing __module__ in their dict is not overridden. This is not inherited. - type_repr(): if __module__ exists and is not "__builtin__", it is included in the string representation (just as it already is for classes). For example <type '__main__.C'>.
-
Guido van Rossum authored
- descrobject.c:descr_check(): only believe None means the same as NULL if the type given is None's type. - typeobject.c:wrap_descr_get(): don't "conventiently" default an absent type to the type of the object argument. Let the called function figure it out.
-
- 15 Aug, 2001 1 commit
-
-
Guido van Rossum authored
operators for which a default implementation exist now work, both in dynamic classes and in static classes, overridden or not. This affects __repr__, __str__, __hash__, __contains__, __nonzero__, __cmp__, and the rich comparisons (__lt__ etc.). For dynamic classes, this meant copying a lot of code from classobject! (XXX There are still some holes, because the comparison code in object.c uses PyInstance_Check(), meaning new-style classes don't get the same dispensation. This needs more thinking.) - Add object.__hash__, object.__repr__, object.__str__. The __str__ dispatcher now calls the __repr__ dispatcher, as it should. - For static classes, the tp_compare, tp_richcompare and tp_hash slots are now inherited together, or not at all. (XXX I fear there are still some situations where you can inherit __hash__ when you shouldn't, but mostly it's OK now, and I think there's no way we can get that 100% right.)
-
- 14 Aug, 2001 1 commit
-
-
Guido van Rossum authored
be inherited in inherit_special(), otherwise dynamic types don't inherit these. Also added some XXX comments about open ends.
-
- 12 Aug, 2001 2 commits
-
-
Guido van Rossum authored
XXX There are still some loose ends: repr(), str(), hash() and comparisons don't inherit a default implementation from object. This must be resolved similarly to the way it's resolved for classic instances.
-
Guido van Rossum authored
XXX This is not sufficient: if a dynamic class has no __repr__ method (for instance), but later one is added, that doesn't add a tp_repr slot, so repr() doesn't call the __repr__ method. To make this work, I'll have to add default implementations of several slots to 'object'. XXX Also, dynamic types currently only inherit slots from their dominant base.
-
- 10 Aug, 2001 2 commits
-
-
Guido van Rossum authored
problem). inherit_slots() is split in two parts: inherit_special() which inherits the flags and a few very special members from the dominant base; inherit_slots() which inherits only regular slots, and is now called for each base in the MRO in turn. These are now both void functions since they don't have error returns. - Added object.__setitem__() back -- for the same reason as object.__new__(): a subclass of object should be able to call object.__new__(). - add_wrappers() was moved around to be closer to where it is used (it was defined together with add_methods() etc., but has nothing to do with these).
-
Guido van Rossum authored
it possible to detect recursive calls early (as opposed to when the stack overflows :-).
-
- 09 Aug, 2001 2 commits
-
-
Guido van Rossum authored
inherited unless *both*: (a) the base type is 'object', and (b) the subtype is not a "heap" type.
-
Guido van Rossum authored
bit. For one, this class: class C(object): def __new__(myclass, ...): ... would have no way to call the __new__ method of its base class, and the workaround (to create an intermediate base class whose __new__ you can call) is ugly. So, I've come up with a better solution that restores object.__new__, but still solves the original problem, which is that built-in and extension types shouldn't inherit object.__new__. The solution is simple: only "heap types" inherit tp_new. Simpler, less code, perfect!
-
- 08 Aug, 2001 2 commits
-
-
Guido van Rossum authored
division. The basic binary operators now all correctly call the __rxxx__ variant when they should. In type_new(), I now make the new type a new-style number unless it inherits from an old-style number that has numeric methods. By way of cosmetics, I've changed the signatures of the SLOT<i> macros to take actual function names and operator names as strings, rather than rely on C preprocessor symbol manipulations. This makes the calls slightly more verbose, but greatly helps simple searches through the file: you can now find out where "__radd__" is used or where the function slot_nb_power() is defined and where it is used.
-
Jack Jansen authored
Removed extraneous semicolons that caused a gazzilion "empty declaration" warnings in the MetroWerks compiler.
-
- 07 Aug, 2001 2 commits
-
-
Guido van Rossum authored
- Add an explicit call to PyType_Ready(&PyList_Type) to pythonrun.c (just for the heck of it, really -- we should either explicitly ready all types, or none).
-
Guido van Rossum authored
- Add comment blocks explaining add_operators() and override_slots(). (This file could use some more explaining, but this is all I had breath for today. :) - Renamed the argument 'base' of add_wrappers() to 'wraps' because it's not a base class (which is what the 'base' identifier is used for elsewhere). Small nits: - Fix add_tp_new_wrapper() to avoid overwriting an existing __new__ descriptor in tp_defined. - In add_operators(), check the return value of add_tp_new_wrapper(). Functional change: - Remove the tp_new functionality from PyBaseObject_Type; this means you can no longer instantiate the 'object' type. It's only useful as a base class. - To make up for the above loss, add tp_new to dynamic types. This has to be done in a hackish way (after override_slots() has been called, with an explicit call to add_tp_new_wrapper() at the very end) because otherwise I ran into recursive calls of slot_tp_new(). Sigh.
-
- 06 Aug, 2001 1 commit
-
-
Guido van Rossum authored
problem brought up in SF bug #444229.
-
- 02 Aug, 2001 2 commits
-
-
Guido van Rossum authored
-
Tim Peters authored
-
- 10 Jun, 2001 1 commit
-
-
Jack Jansen authored
-
- 09 Jun, 2001 1 commit
-
-
Martin v. Löwis authored
case of objects with equal types which support tp_compare. Give type objects a tp_compare function. Also add c<0 tests before a few PyErr_Occurred tests.
-
- 01 Sep, 2000 1 commit
-
-
Guido van Rossum authored
This should match the situation in the 1.6b1 tree.
-
- 09 Jul, 2000 1 commit
-
-
Fred Drake authored
-
- 30 Jun, 2000 1 commit
-
-
Guido van Rossum authored
-