1. 16 Agu, 2002 2 kayıt (commit)
  2. 14 Agu, 2002 1 kayıt (commit)
  3. 13 Agu, 2002 3 kayıt (commit)
  4. 12 Agu, 2002 2 kayıt (commit)
    • Guido van Rossum's avatar
      Fix MSVC warnings. · 3747a0f0
      Guido van Rossum yazdı
      3747a0f0
    • Guido van Rossum's avatar
      Refactor how __dict__ and __weakref__ interact with __slots__. · ad47da07
      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.
      ad47da07
  5. 10 Agu, 2002 1 kayıt (commit)
  6. 09 Agu, 2002 1 kayıt (commit)
    • Guido van Rossum's avatar
      Major speedup for new-style class creation. Turns out there was some · 721f62e2
      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).
      721f62e2
  7. 08 Agu, 2002 2 kayıt (commit)
    • Guido van Rossum's avatar
      Significant speedup in new-style object creation: in slot_tp_new(), · 7bed2132
      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).
      7bed2132
    • Guido van Rossum's avatar
      A modest speedup of object deallocation. call_finalizer() did rather · febd61dc
      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.)
      febd61dc
  8. 07 Agu, 2002 1 kayıt (commit)
    • Guido van Rossum's avatar
      Fix a subtle bug in the trashcan code I added yesterday to · 0906e074
      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.
      0906e074
  9. 06 Agu, 2002 1 kayıt (commit)
    • Guido van Rossum's avatar
      Fix SF bug 574207 (chained __slots__ dealloc segfault). · 22b1387c
      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!
      22b1387c
  10. 01 Agu, 2002 1 kayıt (commit)
  11. 30 Tem, 2002 1 kayıt (commit)
  12. 25 Tem, 2002 2 kayıt (commit)
  13. 17 Tem, 2002 1 kayıt (commit)
    • Jeremy Hylton's avatar
      staticforward bites the dust. · 938ace69
      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.
      938ace69
  14. 16 Tem, 2002 2 kayıt (commit)
  15. 11 Tem, 2002 1 kayıt (commit)
    • Tim Peters's avatar
      object.h special-build macro minefield: renamed all the new lexical · 3459251d
      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.
      3459251d
  16. 24 Haz, 2002 1 kayıt (commit)
  17. 20 Haz, 2002 1 kayıt (commit)
  18. 18 Haz, 2002 1 kayıt (commit)
  19. 14 Haz, 2002 1 kayıt (commit)
  20. 13 Haz, 2002 2 kayıt (commit)
  21. 10 Haz, 2002 3 kayıt (commit)
    • Guido van Rossum's avatar
      Undo the last chunk of the previous patch, putting back a useful · cab05807
      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.
      cab05807
    • Guido van Rossum's avatar
      In the recent python-dev thread "Bizarre new test failure", we · a3862097
      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.
      a3862097
    • Guido van Rossum's avatar
      Three's a charm: yet another fix for SF bug 551412. Thinking again · 23094985
      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.
      23094985
  22. 04 Haz, 2002 1 kayıt (commit)
    • Guido van Rossum's avatar
      Address SF bug 519621: slots weren't traversed by GC. · 9923ffe2
      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.
      9923ffe2
  23. 03 Haz, 2002 1 kayıt (commit)
  24. 24 May, 2002 2 kayıt (commit)
  25. 18 Nis, 2002 2 kayıt (commit)
    • Tim Peters's avatar
    • Guido van Rossum's avatar
      SF bug 542984. · 6ca7d41c
      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.
      6ca7d41c
  26. 15 Nis, 2002 1 kayıt (commit)
  27. 12 Nis, 2002 1 kayıt (commit)
  28. 08 Nis, 2002 1 kayıt (commit)