- 16 Agu, 2002 2 kayıt (commit)
-
-
Guido van Rossum yazdı
-- replace then with slightly faster PyObject_Call(o,a,NULL). (The difference is that the latter requires a to be a tuple; the former allows other values and wraps them in a tuple if necessary; it involves two more levels of C function calls to accomplish all that.)
-
Guido van Rossum yazdı
to inner scope, too.
-
- 14 Agu, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
copy the metatype from the base, the base actually has one!
-
- 13 Agu, 2002 3 kayıt (commit)
-
-
Neal Norwitz yazdı
-
Neal Norwitz yazdı
-
Neal Norwitz yazdı
-
- 12 Agu, 2002 2 kayıt (commit)
-
-
Guido van Rossum yazdı
-
Guido van Rossum yazdı
1. You can now have __dict__ and/or __weakref__ in your __slots__ (before only __weakref__ was supported). This is treated differently than before: it merely sets a flag that the object should support the corresponding magic. 2. Dynamic types now always have descriptors __dict__ and __weakref__ thrust upon them. If the type in fact does not support one or the other, that descriptor's __get__ method will raise AttributeError. 3. (This is the reason for all this; it fixes SF bug 575229, reported by Cesar Douady.) Given this code: class A(object): __slots__ = [] class B(object): pass class C(A, B): __slots__ = [] the class object for C was broken; its size was less than that of B, and some descriptors on B could cause a segfault. C now correctly inherits __weakrefs__ and __dict__ from B, even though A is the "primary" base (C.__base__ is A). 4. Some code cleanup, and a few comments added.
-
- 10 Agu, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
types. This prevents nonsense like 2.__class__ = bool or True.__class__ = int.
-
- 09 Agu, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
trampolining going on with the tp_new descriptor, where the inherited PyType_GenericNew was overwritten with the much slower slot_tp_new which would end up calling tp_new_wrapper which would eventually call PyType_GenericNew. Add a special case for this to update_one_slot(). XXX Hope there isn't a loophole in this. I'll buy the first person to point out a bug in the reasoning a beer. Backport candidate (but I won't do it).
-
- 08 Agu, 2002 2 kayıt (commit)
-
-
Guido van Rossum yazdı
intern the string "__new__" so we can call PyObject_GetAttr() rather than PyObject_GetAttrString(). (Though it's a mystery why slot_tp_new is being called when a class doesn't define __new__. I'll look into that tomorrow.) 2.2 backport candidate (but I won't do it).
-
Guido van Rossum yazdı
a lot of work: it had to save and restore the current exception around a call to lookup_maybe(), because that could fail in rare cases, and most objects don't have a __del__ method, so the whole exercise was usually a waste of time. Changed this to cache the __del__ method in the type object just like all other special methods, in a new slot tp_del. So now subtype_dealloc() can test whether tp_del is NULL and skip the whole exercise if it is. The new slot doesn't need a new flag bit: subtype_dealloc() is only called if the type was dynamically allocated by type_new(), so it's guaranteed to have all current slots. Types defined in C cannot fill in tp_del with a function of their own, so there's no corresponding "wrapper". (That functionality is already available through tp_dealloc.)
-
- 07 Agu, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
subtype_dealloc(). When call_finalizer() failed, it would return without going through the trashcan end macro, thereby unbalancing the trashcan nesting level counter, and thereby defeating the test case (slottrash() in test_descr.py). This in turn meant that the assert in the GC_UNTRACK macro wasn't triggered by the slottrash() test despite a bug in the code: _PyTrash_destroy_chain() calls the dealloc routine with an object that's untracked, and the assert in the GC_UNTRACK macro would fail on this; but because of an earlier test that resurrects an object, causing call_finalizer() to fail and the trashcan nesting level to be unbalanced, so _PyTrash_destroy_chain() was never called. Calling the slottrash() test in isolation *did* trigger the assert, however. So the fix is twofold: (1) call the GC_UnTrack() function instead of the GC_UNTRACK macro, because the function is safe when the object is already untracked; (2) when call_finalizer() fails, jump to a label that exits through the trashcan end macro, keeping the trashcan nesting balanced.
-
- 06 Agu, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
This is inspired by SF patch 581742 (by Jonathan Hogg, who also submitted the bug report, and two other suggested patches), but separates the non-GC case from the GC case to avoid testing for GC several times. Had to fix an assert() from call_finalizer() that asserted that the object wasn't untracked, because it's possible that the object isn't GC'ed!
-
- 01 Agu, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
The __delete__ method wrapper for descriptors was not supported (I added a test, too.) 2.2 bugfix candidate.
-
- 30 Tem, 2002 1 kayıt (commit)
-
-
Neal Norwitz yazdı
-
- 25 Tem, 2002 2 kayıt (commit)
-
-
Jeremy Hylton yazdı
-
Jeremy Hylton yazdı
Fixes SF bug #575773. Bug fix candidate.
-
- 17 Tem, 2002 1 kayıt (commit)
-
-
Jeremy Hylton yazdı
The staticforward define was needed to support certain broken C compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the static keyword when it was used with a forward declaration of a static initialized structure. Standard C allows the forward declaration with static, and we've decided to stop catering to broken C compilers. (In fact, we expect that the compilers are all fixed eight years later.) I'm leaving staticforward and statichere defined in object.h as static. This is only for backwards compatibility with C extensions that might still use it. XXX I haven't updated the documentation.
-
- 16 Tem, 2002 2 kayıt (commit)
-
-
Jeremy Hylton yazdı
If the object is an ExtensionClass, for example, the slot is not even defined. So we must check that the type has the slot (implied by HAVE_CLASS) before calling tp_init().
-
Guido van Rossum yazdı
the right thing even if char is unsigned.
-
- 11 Tem, 2002 1 kayıt (commit)
-
-
Tim Peters yazdı
helper macros to something saner, and used them appropriately in other files too, to reduce #ifdef blocks. classobject.c, instance_dealloc(): One of my worst Python Memories is trying to fix this routine a few years ago when COUNT_ALLOCS was defined but Py_TRACE_REFS wasn't. The special-build code here is way too complicated. Now it's much simpler. Difference: in a Py_TRACE_REFS build, the instance is no longer in the doubly-linked list of live objects while its __del__ method is executing, and that may be visible via sys.getobjects() called from a __del__ method. Tough -- the object is presumed dead while its __del__ is executing anyway, and not calling _Py_NewReference() at the start allows enormous code simplification. typeobject.c, call_finalizer(): The special-build instance_dealloc() pain apparently spread to here too via cut-'n-paste, and this is much simpler now too. In addition, I didn't understand why this routine was calling _PyObject_GC_TRACK() after a resurrection, since there's no plausible way _PyObject_GC_UNTRACK() could have been called on the object by this point. I suspect it was left over from pasting the instance_delloc() code. Instead asserted that the object is still tracked. Caution: I suspect we don't have a test that actually exercises the subtype_dealloc() __del__-resurrected-me code.
-
- 24 Haz, 2002 1 kayıt (commit)
-
-
Raymond Hettinger yazdı
-
- 20 Haz, 2002 1 kayıt (commit)
-
-
Raymond Hettinger yazdı
-
- 18 Haz, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
In a fresh interpreter, type.mro(tuple) would segfault, because PyType_Ready() isn't called for tuple yet. To fix, call PyType_Ready(type) if type->tp_dict is NULL.
-
- 14 Haz, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
gotten from a weak reference to NULL instead of to None. This caused the following assert() to fail (but only in 2.2 in the debug build -- I have to find a better test case). Will backport.
-
- 13 Haz, 2002 2 kayıt (commit)
-
-
Martin v. Löwis yazdı
-
Guido van Rossum yazdı
473985. Through a subtle rearrangement of some members in the etype struct (!), mapping methods are now preferred over sequence methods, which is necessary to support str.__getitem__("hello", slice(4)) etc.
-
- 10 Haz, 2002 3 kayıt (commit)
-
-
Guido van Rossum yazdı
assert into PyType_Ready(): now that we're not clearing tp_dict, we can assert that it's non-NULL again.
-
Guido van Rossum yazdı
discovered that subtype_traverse must traverse the type if it is a heap type, because otherwise some cycles involving a type and its instance would not be collected. Simplest example: while 1: class C(object): pass C.ref = C() This program grows without bounds before this fix. (It grows ever slower since it spends ever more time in the collector.) Simply adding the right visit() call to subtype_traverse() revealed other problems. With MvL's help we re-learned that type_clear() doesn't have to clear *all* references, only the ones that may not be cleared by other means. Careful analysis (see comments in the code) revealed that only tp_mro needs to be cleared. (The previous checkin to this file adds a test for tp_mro==NULL to _PyType_Lookup() that's essential to prevent crashes due to tp_mro being NULL when subtype_dealloc() tries to look for a __del__ method.) The same kind of analysis also revealed that subtype_clear() doesn't need to clear the instance dict. With this fix, a useful property of the collector is once again guaranteed: a single gc.collect() call will clear out all garbage. (It didn't always before, which put us on the track of this bug.) Will backport to 2.2.
-
Guido van Rossum yazdı
about the test case, slot_nb_power gets called on behalf of its second argument, but with a non-None modulus it wouldn't check this, and believes it is called on behalf of its first argument. Fix this properly, and get rid of the code in _PyType_Lookup() that tries to call _PyType_Ready(). But do leave a check for a NULL tp_mro there, because this can still legitimately occur. I'll fix this in 2.2.x too.
-
- 04 Haz, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also tightened the rules for slot names: they must now be proper identifiers (ignoring the dirty little fact that <ctype.h> is locale sensitive). Also set mp->flags = READONLY for the __weakref__ pseudo-slot. Most of this is a 2.2 bugfix candidate; I'll apply it there myself.
-
- 03 Haz, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
_PyType_Lookup(). Decided to clear the error condition in the unfortunate but unlikely case that PyType_Ready() fails. Will fix in 2.2.x too.
-
- 24 May, 2002 2 kayıt (commit)
-
-
Guido van Rossum yazdı
whose tp_mro hasn't been initialized, it would dump core. Fix this by checking for NULL and calling PyType_Ready(). Will fix this in 2.2.1 too.
-
Guido van Rossum yazdı
different free or alloc slot.
-
- 18 Nis, 2002 2 kayıt (commit)
-
-
Tim Peters yazdı
-
Guido van Rossum yazdı
Change type_get_doc (the get function for __doc__) to look in tp_dict more often, and if it finds a descriptor in tp_dict, to call it (with a NULL instance). This means you can add a __doc__ descriptor to a new-style class that returns instance docs when called on an instance, and class docs when called on a class -- or the same docs in either case, but lazily computed. I'll also check this into the 2.2 maintenance branch.
-
- 15 Nis, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
A stupid bug in object_set_class(): didn't check for value==NULL before checking its type. Bugfix candidate.
-
- 12 Nis, 2002 1 kayıt (commit)
-
-
Neil Schemenauer yazdı
PyObject_Del and PyObject_GC_Del can now be used as a function designators.
-
- 08 Nis, 2002 1 kayıt (commit)
-
-
Guido van Rossum yazdı
when PyType_Ready() was called, if ob_type was found to be NULL, it was always set to &PyType_Type; now it is set to base->ob_type, where base is tp_base, defaulting to &PyObject_Type. - PyType_Ready() accidentally did not inherit tp_is_gc; now it does. Bugfix candidate.
-