1. 30 Aug, 2001 3 commits
  2. 29 Aug, 2001 2 commits
  3. 28 Aug, 2001 3 commits
  4. 24 Aug, 2001 3 commits
  5. 22 Aug, 2001 1 commit
  6. 17 Aug, 2001 4 commits
    • Guido van Rossum's avatar
      Address SF bug #442813. The sequence getitem wrappers should do · 5d815f32
      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.)
      5d815f32
    • Guido van Rossum's avatar
      Weak reference support, closing SF bug #451773. · 9676b22c
      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?)
      9676b22c
    • Guido van Rossum's avatar
      type_new(): look for __dynamic__ at the module level (after looking in · 1a49350e
      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.
      1a49350e
    • Guido van Rossum's avatar
      type_new(): only defer to the winning metatype if it's different from · 8d32c8b5
      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.
      8d32c8b5
  7. 16 Aug, 2001 4 commits
  8. 15 Aug, 2001 1 commit
    • Guido van Rossum's avatar
      - Another big step in the right direction. All the overridable · b8f63664
      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.)
      b8f63664
  9. 14 Aug, 2001 1 commit
  10. 12 Aug, 2001 2 commits
    • Guido van Rossum's avatar
      Make dynamic types work as intended. Or at least more so. · 8e24818c
      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.
      8e24818c
    • Guido van Rossum's avatar
      Temporary stop-gap fix for dynamic classes, so they pass the test. · 8de8680d
      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.
      8de8680d
  11. 10 Aug, 2001 2 commits
    • Guido van Rossum's avatar
      - Big changes to fix SF bug #442833 (a nasty multiple inheritance · 13d52f0b
      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).
      13d52f0b
    • Guido van Rossum's avatar
      Change PyType_Ready() to use the READY and READYING flags. This makes · d614f977
      Guido van Rossum authored
      it possible to detect recursive calls early (as opposed to when the
      stack overflows :-).
      d614f977
  12. 09 Aug, 2001 2 commits
    • Guido van Rossum's avatar
      Sigh. Strengthen the resriction of the previous checkin: tp_new is · 29687cd2
      Guido van Rossum authored
      inherited unless *both*: (a) the base type is 'object', and (b) the
      subtype is not a "heap" type.
      29687cd2
    • Guido van Rossum's avatar
      Thinking back to the 2.22 revision, I didn't like what I did there one · c11e192d
      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!
      c11e192d
  13. 08 Aug, 2001 2 commits
    • Guido van Rossum's avatar
      Proper support for binary operators, including true division and floor · dc91b99f
      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.
      dc91b99f
    • Jack Jansen's avatar
      Removed extraneous semicolons that caused a gazzilion "empty declaration"... · 8e938b42
      Jack Jansen authored
      Removed extraneous semicolons that caused a gazzilion "empty declaration" warnings in the MetroWerks compiler.
      8e938b42
  14. 07 Aug, 2001 2 commits
    • Guido van Rossum's avatar
      - Rename PyType_InitDict() to PyType_Ready(). · 528b7eb0
      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).
      528b7eb0
    • Guido van Rossum's avatar
      Cosmetics: · f040ede6
      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.
      f040ede6
  15. 06 Aug, 2001 1 commit
  16. 02 Aug, 2001 2 commits
  17. 10 Jun, 2001 1 commit
  18. 09 Jun, 2001 1 commit
  19. 01 Sep, 2000 1 commit
  20. 09 Jul, 2000 1 commit
  21. 30 Jun, 2000 1 commit