Ticket #10467: 10467-attribute-referee.patch

File 10467-attribute-referee.patch, 1.3 KB (added by robertwb, 11 years ago)
  • sage/structure/sage_object.pyx

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1292303979 28800
    # Node ID 078492ed0ccecdfe9be38841769c0b0d0ba47e15
    # Parent  8f6ddf2d5b8150df0f81d2bf2756a5383959667a
    [mq]: 10467-attribute-referee.patch
    
    diff -r 8f6ddf2d5b81 -r 078492ed0cce sage/structure/sage_object.pyx
    a b  
    146146        except:
    147147            pass
    148148        try:
    149             return self._repr_()
     149            repr_func = self._repr_
    150150        except AttributeError:
    151151            return str(type(self))
     152        else:
     153            return repr_func()
    152154
    153155    def __hash__(self):
    154156        return hash(self.__repr__())
     
    424426            except (KeyError, ValueError):
    425427                pass
    426428        nm = I.name()
    427         try:
    428             s = self.__getattribute__('_%s_init_'%nm)()
    429         except AttributeError:
     429        init_func = getattr(self, '_%s_init_' % nm, None)
     430        if init_func is not None:
     431            s = init_func()
     432        else:
    430433            try:
    431               s = self._interface_init_(I)
     434                s = self._interface_init_(I)
    432435            except:
    433436                raise NotImplementedError, "coercion of object %s to %s not implemented:\n%s\n%s"%\
    434437                  (repr(self), I)