1. 10 Ara, 2005 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Add const to several API functions that take char *. · af68c874
      Jeremy Hylton yazdı
      In C++, it's an error to pass a string literal to a char* function
      without a const_cast().  Rather than require every C++ extension
      module to put a cast around string literals, fix the API to state the
      const-ness.
      
      I focused on parts of the API where people usually pass literals:
      PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
      slots, etc.  Predictably, there were a large set of functions that
      needed to be fixed as a result of these changes.  The most pervasive
      change was to make the keyword args list passed to
      PyArg_ParseTupleAndKewords() to be a const char *kwlist[].
      
      One cast was required as a result of the changes:  A type object
      mallocs the memory for its tp_doc slot and later frees it.
      PyTypeObject says that tp_doc is const char *; but if the type was
      created by type_new(), we know it is safe to cast to char *.
      af68c874
  2. 12 Agu, 2005 1 kayıt (commit)
  3. 23 Eyl, 2004 1 kayıt (commit)
  4. 01 Eyl, 2004 1 kayıt (commit)
  5. 22 Tem, 2004 1 kayıt (commit)
    • Tim Peters's avatar
      SF bug 994255: Py_RETURN_NONE causes too much warnings · 5980ff2d
      Tim Peters yazdı
      Rewrote Py_RETURN_{NONE, TRUE, FALSE} to expand to comma expressions
      rather than "do {} while(0)" thingies.  The OP complained because he
      likes using MS /W4 sometimes, and then all his uses of these things
      generate nuisance warnings about testing a constant expression (in
      the "while(0)" part).  Comma expressions don't have this problem
      (although it's a lucky accident that comma expressions suffice for these
      macros!).
      5980ff2d
  6. 14 Tem, 2004 1 kayıt (commit)
  7. 22 Nis, 2004 1 kayıt (commit)
  8. 09 Kas, 2003 1 kayıt (commit)
  9. 19 Eki, 2003 3 kayıt (commit)
  10. 23 May, 2003 2 kayıt (commit)
  11. 20 May, 2003 1 kayıt (commit)
  12. 17 Nis, 2003 1 kayıt (commit)
    • Tim Peters's avatar
      _Py_PrintReferences(): Changed to print object address at start of each · 269b2a67
      Tim Peters yazdı
      new line.
      
      New pvt API function _Py_PrintReferenceAddresses():  Prints only the
      addresses and refcnts of the live objects.  This is always safe to call,
      because it has no dependence on Python's C API.
      
      Py_Finalize():  If envar PYTHONDUMPREFS is set, call (the new)
      _Py_PrintReferenceAddresses() right before dumping final pymalloc stats.
      We can't print the reprs of the objects here because too much of the
      interpreter has been shut down.  You need to correlate the addresses
      displayed here with the object reprs printed by the earlier
      PYTHONDUMPREFS call to _Py_PrintReferences().
      269b2a67
  13. 23 Mar, 2003 2 kayıt (commit)
    • Tim Peters's avatar
      Improved new Py_TRACE_REFS gimmicks. · 7571a0fb
      Tim Peters yazdı
      Arranged that all the objects exposed by __builtin__ appear in the list
      of all objects.  I basically peed away two days tracking down a mystery
      leak in sys.gettotalrefcount() in a ZODB app (== tons of code), because
      the object leaking the references didn't appear in the sys.getobjects(0)
      list.  The object happened to be False.  Now False is in the list, along
      with other popular & previously missing leak candidates (like None).
      Alas, we still don't have a choke point covering *all* Python objects,
      so the list of all objects may still be incomplete.
      7571a0fb
    • Tim Peters's avatar
      Refactored some of the Py_TRACE_REFS code. New private API function · 36eb4dfb
      Tim Peters yazdı
      _Py_AddToAllObjects() that simply inserts an object at the front of
      the doubly-linked list of all objects.  Changed PyType_Ready() (the
       closest thing we've got to a choke point for type objects) to call
      that.
      36eb4dfb
  14. 17 Mar, 2003 2 kayıt (commit)
  15. 07 Mar, 2003 1 kayıt (commit)
  16. 17 Kas, 2002 1 kayıt (commit)
  17. 08 Agu, 2002 1 kayıt (commit)
    • 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
  18. 07 Agu, 2002 1 kayıt (commit)
  19. 29 Tem, 2002 1 kayıt (commit)
  20. 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
  21. 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
  22. 10 Tem, 2002 1 kayıt (commit)
    • Tim Peters's avatar
      Uglified the new Py_REF_DEBUG (etc) lexical helper macro definitions so · 57f4ddd6
      Tim Peters yazdı
      that their uses can be prettier.  I've come to despise the names I picked
      for these things, though, and expect to change all of them -- I changed
      a bunch of other files to use them (replacing #ifdef blocks), but the
      names were so obscure out of context that I backed that all out again.
      57f4ddd6
  23. 09 Tem, 2002 1 kayıt (commit)
    • Tim Peters's avatar
      The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield: added · 7c321a80
      Tim Peters yazdı
      more trivial lexical helper macros so that uses of these guys expand
      to nothing at all when they're not enabled.  This should help sub-
      standard compilers that can't do a good job of optimizing away the
      previous "(void)0" expressions.
      
      Py_DECREF:  There's only one definition of this now.  Yay!  That
      was that last one in the family defined multiple times in an #ifdef
      maze.
      
      Py_FatalError():  Changed the char* signature to const char*.
      
      _Py_NegativeRefcount():  New helper function for the Py_REF_DEBUG
      expansion of Py_DECREF.  Calling an external function cuts down on
      the volume of generated code.  The previous inline expansion of abort()
      didn't work as intended on Windows (the program often kept going, and
      the error msg scrolled off the screen unseen).  _Py_NegativeRefcount
      calls Py_FatalError instead, which captures our best knowledge of
      how to abort effectively across platforms.
      7c321a80
  24. 07 Tem, 2002 3 kayıt (commit)
    • Tim Peters's avatar
      Rearranged and added comments to object.h, to clarify many things · 4be93d0e
      Tim Peters yazdı
      that have taken me "too long" to reverse-engineer over the years.
      Vastly reduced the nesting level and redundancy of #ifdef-ery.
      Took a light stab at repairing comments that are no longer true.
      
      sys_gettotalrefcount():  Changed to enable under Py_REF_DEBUG.
      It was enabled under Py_TRACE_REFS, which was much heavier than
      necessary.  sys.gettotalrefcount() is now available in a
      Py_REF_DEBUG-only build.
      4be93d0e
    • Tim Peters's avatar
      Trashcan cleanup: Now that cyclic gc is always there, the trashcan · 803526b9
      Tim Peters yazdı
      mechanism is no longer evil:  it no longer plays dangerous games with
      the type pointer or refcounts, and objects in extension modules can play
      along too without needing to edit the core first.
      
      Rewrote all the comments to explain this, and (I hope) give clear
      guidance to extension authors who do want to play along.  Documented
      all the functions.  Added more asserts (it may no longer be evil, but
      it's still dangerous <0.9 wink>).  Rearranged the generated code to
      make it clearer, and to tolerate either the presence or absence of a
      semicolon after the macros.  Rewrote _PyTrash_destroy_chain() to call
      tp_dealloc directly; it was doing a Py_DECREF again, and that has all
      sorts of obscure distorting effects in non-release builds (Py_DECREF
      was already called on the object!).  Removed Christian's little "embedded
      change log" comments -- that's what checkin messages are for, and since
      it was impossible to correlate the comments with the code that changed,
      I found them merely distracting.
      803526b9
    • Tim Peters's avatar
      Removed WITH_CYCLE_GC #ifdef-ery. Holes: · 943382c8
      Tim Peters yazdı
      + I'm not sure what to do about configure.in.  Left it alone.
      
      + Ditto pyexpat.c.  Fred or Martin will know what to do.
      943382c8
  25. 12 Nis, 2002 1 kayıt (commit)
  26. 03 Nis, 2002 1 kayıt (commit)
    • Guido van Rossum's avatar
      Add the 'bool' type and its values 'False' and 'True', as described in · 77f6a65e
      Guido van Rossum yazdı
      PEP 285.  Everything described in the PEP is here, and there is even
      some documentation.  I had to fix 12 unit tests; all but one of these
      were printing Boolean outcomes that changed from 0/1 to False/True.
      (The exception is test_unicode.py, which did a type(x) == type(y)
      style comparison.  I could've fixed that with a single line using
      issubtype(x, type(y)), but instead chose to be explicit about those
      places where a bool is expected.
      
      Still to do: perhaps more documentation; change standard library
      modules to return False/True from predicates.
      77f6a65e
  27. 08 Ara, 2001 1 kayıt (commit)
    • Guido van Rossum's avatar
      Patch supplied by Burton Radons for his own SF bug #487390: Modifying · 14648396
      Guido van Rossum yazdı
      type.__module__ behavior.
      
      This adds the module name and a dot in front of the type name in every
      type object initializer, except for built-in types (and those that
      already had this).  Note that it touches lots of Mac modules -- I have
      no way to test these but the changes look right.  Apologies if they're
      not.  This also touches the weakref docs, which contains a sample type
      object initializer.  It also touches the mmap test output, because the
      mmap type's repr is included in that output.  It touches object.h to
      put the correct description in a comment.
      14648396
  28. 27 Eki, 2001 1 kayıt (commit)
    • Tim Peters's avatar
      SF bug #475327: type() produces incorrect error msg · 3abca127
      Tim Peters yazdı
      object.h:  Added PyType_CheckExact macro.
      
      typeobject.c, type_new():
      
      + Use the new macro.
      + Assert that the arguments have the right types rather than do incomplete
        runtime checks "sometimes".
      + If this isn't the 1-argument flavor() of type, and there aren't 3 args
        total, produce a "types() takes 1 or 3 args" msg before
        PyArg_ParseTupleAndKeywords produces a "takes exactly 3" msg.
      3abca127
  29. 15 Eki, 2001 2 kayıt (commit)
  30. 08 Eki, 2001 1 kayıt (commit)
    • Guido van Rossum's avatar
      Keep track of a type's subclasses (subtypes), in tp_subclasses, which · 1c45073a
      Guido van Rossum yazdı
      is a list of weak references to types (new-style classes).  Make this
      accessible to Python as the function __subclasses__ which returns a
      list of types -- we don't want Python programmers to be able to
      manipulate the raw list.
      
      In order to make this possible, I also had to add weak reference
      support to type objects.
      
      This will eventually be used together with a trap on attribute
      assignment for dynamic classes for a major speed-up without losing the
      dynamic properties of types: when a __foo__ method is added to a
      class, the class and all its subclasses will get an appropriate tp_foo
      slot function.
      1c45073a
  31. 05 Eki, 2001 1 kayıt (commit)
  32. 02 Eki, 2001 1 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