#14471: Exception KeyError: in WeakValueDictionary remove ignored
---------------------------+------------------------------------------------
       Reporter:  vbraun   |         Owner:  rlm      
           Type:  defect   |        Status:  new      
       Priority:  major    |     Milestone:  sage-5.10
      Component:  memleak  |    Resolution:           
       Keywords:           |   Work issues:           
Report Upstream:  N/A      |     Reviewers:           
        Authors:           |     Merged in:           
   Dependencies:           |      Stopgaps:           
---------------------------+------------------------------------------------

Comment (by nbruin):

 Replying to [comment:5 vbraun]:
 > {{{
 >     Exception KeyError: (((<class 'sage.categories.algebras.Algebras'>,
 Callable function ring with arguments (x, y)), ()),) in <function remove
 at 0x1acf758> ignored
 > }}}
 This entry is produced by the `__call__` doctest in `matrix0.pyx`:
 {{{#!diff
             sage: f(x,y) = x^2+y
             sage: m = matrix([[f,f*f],[f^3,f^4]]); m
             [    (x, y) |--> x^2 + y (x, y) |--> (x^2 + y)^2]
             [(x, y) |--> (x^2 + y)^3 (x, y) |--> (x^2 + y)^4]
             sage: m(1,2)
             [ 3  9]
             [27 81]
             sage: m(y=2,x=1)
             [ 3  9]
             [27 81]
             sage: m(2,1)
             [  5  25]
             [125 625]
 +           sage: D=UniqueRepresentation.__classcall__.get_cache()
 +           sage: [k for k in D.data.keys() if k not in D.data]
 +           []
 }}}
 With the added doctest, we get different behaviour depending on whether
 attachment:trac_14471_demonstrate.patch is applied or not: Without the
 patch, the test passes; with the patch the test fails. That means that the
 line
 {{{
 hasattr(obj, '_foobar_')
 }}}
 changes the hash of one of the key components involved; probably the
 "callable function ring", i.e., `parent(f)`. Indeed:
 {{{
 sage: f(x,y) = x^2+y
 sage: H=hash(parent(f))
 sage: m = matrix([[f,f*f],[f^3,f^4]]);
 sage: hasattr(m,'a')
 False
 sage: H == hash(parent(f))
 False
 }}}
 that last one's really bad! The `hasattr` on that matrix apparently
 clobbers the hash of its base ring!

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14471#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to