3 | | Under some circumstances the !WeakValueDictionary remove callback is being called when the internal dictionary is in a bad state. The attached patch [attachment:trac_14471_demonstrate.patch] to demonstrate the issue just calls `hasattr` from the displayhook, which ends up generating weak references somewhere. The exact place for where the exception occurs depends on the garbage collector, but I always do get some unwanted exceptions with it. |

4 | | {{{ |

5 | | sage -t devel/sage/sage/matrix/matrix0.pyx |

6 | | Exception KeyError: (((<class 'sage.matrix.matrix_space.MatrixSpace'>, Callable function ring with arguments (x, y), 2, 2, False), ()),) in <function remove at 0x18d8758> ignored |

7 | | ********************************************************************** |

8 | | File "devel/sage/sage/matrix/matrix0.pyx", line 3370, in sage.matrix.matrix0.Matrix.is_hermitian |

9 | | Failed example: |

10 | | B.is_hermitian() |

11 | | Expected: |

12 | | True |

13 | | Got: |

14 | | Exception KeyError: (((<class 'sage.categories.algebras.Algebras'>, Callable function ring with arguments (x, y)), ()),) in <function remove at 0x18d8758> ignored |

15 | | True |

16 | | }}} |

| 3 | One such instance is that, under some circumstances, a !WeakValueDictionary remove callback is being called but cannot find the object in the dictionary since the hash changed. |