Ticket #13043: trac_13043.patch

File trac_13043.patch, 1.4 KB (added by saraedum, 9 years ago)
  • sage/structure/parent.pyx

    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    Trac 13043: fixed a bug in the dir_with_other_class() helper function
    
    diff --git a/sage/structure/parent.pyx b/sage/structure/parent.pyx
    index 05a1db4..705d8e7 100644
    a b def dir_with_other_class(self, cls): 
    375375        False
    376376        sage: sage.structure.parent.dir_with_other_class(x, B)
    377377        [..., 'a', 'b']
     378
     379    TESTS:
     380
     381    Check that #13043 is fixed::
     382
     383        sage: len(dir(RIF))==len(set(dir(RIF)))
     384        True
    378385    """
     386    ret = set()
    379387    # This tries to emulate the standard dir function
    380388    # Is there a better way to call dir on self, while ignoring this
    381389    # __dir__? Using dir(super(A, self)) does not work since the
    382390    # attributes coming from subclasses of A will be ignored
    383     iterator = dir(self.__class__)
     391    ret.update(dir(self.__class__))
    384392    if hasattr(self, "__dict__"):
    385         iterator = unique_merge(iterator, self.__dict__.keys())
     393        ret.update(self.__dict__.keys())
    386394    if not isinstance(self, cls):
    387         iterator = unique_merge(iterator, dir(cls))
    388     return list(iterator)
    389 
     395        ret.update(dir(cls))
     396    return sorted(ret)
    390397
    391398###############################################################################
    392399#   Sage: System for Algebra and Geometry Experimentation