Ticket #9251: trac_9251-lazy_attribute_cython-fh.patch

File trac_9251-lazy_attribute_cython-fh.patch, 1.5 KB (added by Florent Hivert, 12 years ago)
  • sage/misc/lazy_attribute.py

    # HG changeset patch
    # User Florent Hivert <Florent.Hivert@univ-rouen.fr>
    # Date 1276731508 -7200
    # Node ID cbb865e36402976f2f74d6bad09f36a824309b78
    # Parent  9c0d7d9b682420d61c03ba0bd3369dfe8af716c9
    #9251: Lazy attribute does not properly handles the doc of Cython methods
    
    diff --git a/sage/misc/lazy_attribute.py b/sage/misc/lazy_attribute.py
    a b class lazy_attribute(object): 
    447447            'f'
    448448            sage: x.__module__
    449449            '__main__'
     450
     451        TESTS:
     452
     453        We check that #9251 is solved::
     454
     455            sage: Parent.element_class
     456            <sage.misc.lazy_attribute.lazy_attribute object at 0x...>
     457            sage: Parent.element_class.__doc__[64:120]
     458            'The (default) class for the elements of this parent\n\n   '
     459            sage: Parent.element_class.__name__
     460            'element_class'
     461            sage: Parent.element_class.__module__
     462            'sage.misc.lazy_attribute'
    450463        """
    451464        self.f = f
    452465        if hasattr(f, "func_doc"):
    453466            self.__doc__ = f.func_doc
     467        elif hasattr(f, "__doc__"): # Needed to handles Cython methods
     468            self.__doc__ = f.__doc__
    454469        if hasattr(f, "func_name"):
    455470            self.__name__ = f.func_name
     471        elif hasattr(f, "__name__"): # Needed to handles Cython methods
     472            self.__name__ = f.__name__
    456473        if hasattr(f, "__module__"):
    457474            self.__module__ = f.__module__
    458475