1. 07 Mar, 2006 1 kayıt (commit)
  2. 30 Eki, 2004 1 kayıt (commit)
    • Tim Peters's avatar
      SF 1055820: weakref callback vs gc vs threads · ead8b7ab
      Tim Peters yazdı
      In cyclic gc, clear weakrefs to unreachable objects before allowing any
      Python code (weakref callbacks or __del__ methods) to run.
      
      This is a critical bugfix, affecting all versions of Python since weakrefs
      were introduced.  I'll backport to 2.3.
      ead8b7ab
  3. 08 Nis, 2003 3 kayıt (commit)
  4. 07 Nis, 2003 1 kayıt (commit)
    • Tim Peters's avatar
      Reworked has_finalizer() to use the new _PyObject_Lookup() instead · f6b8045c
      Tim Peters yazdı
      of PyObject_HasAttr(); the former promises never to execute
      arbitrary Python code.  Undid many of the changes recently made to
      worm around the worst consequences of that PyObject_HasAttr() could
      execute arbitrary Python code.
      
      Compatibility is hard to discuss, because the dangerous cases are
      so perverse, and much of this appears to rely on implementation
      accidents.
      
      To start with, using hasattr() to check for __del__ wasn't only
      dangerous, in some cases it was wrong:  if an instance of an old-
      style class didn't have "__del__" in its instance dict or in any
      base class dict, but a getattr hook said __del__ existed, then
      hasattr() said "yes, this object has a __del__".  But
      instance_dealloc() ignores the possibility of getattr hooks when
      looking for a __del__, so while object.__del__ succeeds, no
      __del__ method is called when the object is deleted.  gc was
      therefore incorrect in believing that the object had a finalizer.
      
      The new method doesn't suffer that problem (like instance_dealloc(),
      _PyObject_Lookup() doesn't believe __del__ exists in that case), but
      does suffer a somewhat opposite-- and even more obscure --oddity:
      if an instance of an old-style class doesn't have "__del__" in its
      instance dict, and a base class does have "__del__" in its dict,
      and the first base class with a "__del__" associates it with a
      descriptor (an object with a __get__ method), *and* if that
      descriptor raises an exception when __get__ is called, then
      (a) the current method believes the instance does have a __del__,
      but (b) hasattr() does not believe the instance has a __del__.
      
      While these disagree, I believe the new method is "more correct":
      because the descriptor *will* be called when the object is
      destructed, it can execute arbitrary Python code at the time the
      object is destructed, and that's really what gc means by "has a
      finalizer":  not specifically a __del__ method, but more generally
      the possibility of executing arbitrary Python code at object
      destruction time.  Code in a descriptor's __get__() executed at
      destruction time can be just as problematic as code in a
      __del__() executed then.
      
      So I believe the new method is better on all counts.
      
      Bugfix candidate, but it's unclear to me how all this differs in
      the 2.2 branch (e.g., new-style and old-style classes already
      took different gc paths in 2.3 before this last round of patches,
      but don't in the 2.2 branch).
      f6b8045c
  5. 06 Nis, 2003 1 kayıt (commit)
    • Tim Peters's avatar
      Reworked move_finalizer_reachable() to create two distinct lists: · bf384c25
      Tim Peters yazdı
      externally unreachable objects with finalizers, and externally unreachable
      objects without finalizers reachable from such objects.  This allows us
      to call has_finalizer() at most once per object, and so limit the pain of
      nasty getattr hooks.  This fixes the failing "boom 2" example Jeremy
      posted (a non-printing variant of which is now part of test_gc), via never
      triggering the nasty part of its __getattr__ method.
      bf384c25
  6. 05 Nis, 2003 1 kayıt (commit)
  7. 04 Nis, 2003 1 kayıt (commit)
  8. 11 Agu, 2002 1 kayıt (commit)
  9. 10 Agu, 2002 3 kayıt (commit)
  10. 09 Agu, 2002 1 kayıt (commit)
  11. 23 Tem, 2002 1 kayıt (commit)
    • Barry Warsaw's avatar
      Get rid of relative imports in all unittests. Now anything that · 04f357cf
      Barry Warsaw yazdı
      imports e.g. test_support must do so using an absolute package name
      such as "import test.test_support" or "from test import test_support".
      
      This also updates the README in Lib/test, and gets rid of the
      duplicate data dirctory in Lib/test/data (replaced by
      Lib/email/test/data).
      
      Now Tim and Jack can have at it. :)
      04f357cf
  12. 11 Tem, 2002 1 kayıt (commit)
    • Tim Peters's avatar
      test_trashcan() and supporting class Ouch(): Jeremy noted that this test · c62b95e5
      Tim Peters yazdı
      takes much longer to run in the context of the test suite than when run in
      isolation.  That's because it forces a large number of full collections,
      which take time proportional to the total number of gc'ed objects in the
      whole system.
      
      But since the dangerous implementation trickery that caused this test to
      fail in 2.0, 2.1 and 2.2 doesn't exist in 2.3 anymore (the trashcan
      mechanism stopped doing evil things when the possibility for compiling
      without cyclic gc was taken away), such an expensive test is no longer
      justified.  This checkin leaves the test intact, but fiddles the
      constants to reduce the runtime by about a factor of 5.
      c62b95e5
  13. 13 Haz, 2002 1 kayıt (commit)
  14. 12 Haz, 2002 1 kayıt (commit)
  15. 28 Mar, 2002 2 kayıt (commit)
  16. 15 Eki, 2001 1 kayıt (commit)
  17. 05 Eki, 2001 1 kayıt (commit)
    • Guido van Rossum's avatar
      Enable GC for new-style instances. This touches lots of files, since · 9475a231
      Guido van Rossum yazdı
      many types were subclassable but had a xxx_dealloc function that
      called PyObject_DEL(self) directly instead of deferring to
      self->ob_type->tp_free(self).  It is permissible to set tp_free in the
      type object directly to _PyObject_Del, for non-GC types, or to
      _PyObject_GC_Del, for GC types.  Still, PyObject_DEL was a tad faster,
      so I'm fearing that our pystone rating is going down again.  I'm not
      sure if doing something like
      
      void xxx_dealloc(PyObject *self)
      {
      	if (PyXxxCheckExact(self))
      		PyObject_DEL(self);
      	else
      		self->ob_type->tp_free(self);
      }
      
      is any faster than always calling the else branch, so I haven't
      attempted that -- however those types whose own dealloc is fancier
      (int, float, unicode) do use this pattern.
      9475a231
  18. 02 Eki, 2001 2 kayıt (commit)
    • Guido van Rossum's avatar
      Add Garbage Collection support to new-style classes (not yet to their · 048eb75c
      Guido van Rossum yazdı
      instances).
      
      Also added GC support to various auxiliary types: super, property,
      descriptors, wrappers, dictproxy.  (Only type objects have a tp_clear
      field; the other types are.)
      
      One change was necessary to the GC infrastructure.  We have statically
      allocated type objects that don't have a GC header (and can't easily
      be given one) and heap-allocated type objects that do have a GC
      header.  Giving these different metatypes would be really ugly: I
      tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
      invent a new name for the new metatype and make it a built-in, change
      affected tests...  In short, a mess.  So instead, we add a new type
      slot tp_is_gc, which is a simple Boolean function that determines
      whether a particular instance has GC headers or not.  This slot is
      only relevant for types that have the (new) GC flag bit set.  If the
      tp_is_gc slot is NULL (by far the most common case), all instances of
      the type are deemed to have GC headers.  This slot is called by the
      PyObject_IS_GC() macro (which is only used twice, both times in
      gcmodule.c).
      
      I also changed the extern declarations for a bunch of GC-related
      functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
      only declared them when WITH_CYCLE_GC was defined, but I needed to be
      able to reference them without #ifdefs.  (When WITH_CYCLE_GC is not
      defined, they do the same as their non-GC counterparts anyway.)
      048eb75c
    • Guido van Rossum's avatar
      The error reporting here was a bit sparse. In verbose mode, the code · c907bd89
      Guido van Rossum yazdı
      in run_test() referenced two non-existent variables, and in
      non-verbose mode, the tests didn't report the actual number, when it
      differed from the expected number.  Fixed this.
      
      Also added an extra call to gc.collect() at the start of test_all().
      This will be needed when I check in the changes to add GC to new-style
      classes.
      c907bd89
  19. 12 Tem, 2001 1 kayıt (commit)
  20. 17 Ock, 2001 1 kayıt (commit)
  21. 23 Eki, 2000 1 kayıt (commit)
  22. 22 Eyl, 2000 1 kayıt (commit)
  23. 15 Eyl, 2000 1 kayıt (commit)
  24. 06 Agu, 2000 1 kayıt (commit)
  25. 30 Haz, 2000 2 kayıt (commit)