• Guido van Rossum's avatar
    Implement the intention of SF patch 472523 (but coded differently). · a407300c
    Guido van Rossum authored
    In the past, an object's tp_compare could return any value.  In 2.2
    the docs were tightened to require it to return -1, 0 or 1; and -1 for
    an error.
    
    We now issue a warning if the value is not in this range.  When an
    exception is raised, we allow -1 or -2 as return value, since -2 will
    the recommended return value for errors in the future.  (Eventually
    tp_compare will also be allowed to return +2, to indicate
    NotImplemented; but that can only be implemented once we know all
    extensions return a value in [-2...1].  Or perhaps it will require the
    type to set a flag bit.)
    
    I haven't decided yet whether to backport this to 2.2.x.  The patch
    applies fine.  But is it fair to start warning in 2.2.2 about code
    that worked flawlessly in 2.2.1?
    a407300c
object.c 48.5 KB