Jesse Bacon added the comment:

Thank you for the second eyes. 
I just verified that it works using the standard python shell.  It looks like 
the bug is in IPython.  I’ll post it there.

In [7]: class A:
   ...:     def __init__(self, value):
   ...:         self.value = value
   ...:     def __repr__(self):
   ...:         return str(self.value)
   ...:     

In [8]: a = A(10)

In [9]: d = weakref.WeakValueDictionary()

In [10]: d['primary'] = a

In [11]: d['primary'] 
Out[11]: 10

In [12]: del a

In [13]: gc.collect()
Out[13]: 148

In [14]: d['primary']
Out[14]: 10

In [15]: 

sincerely,

Jesse Bacon

> On May 3, 2015, at 8:54 PM, R. David Murray <rep...@bugs.python.org> wrote:
> 
> 
> R. David Murray added the comment:
> 
> If I run the example code you pasted using 2.7, I get a KeyError.  So the 
> example looks correct to me.
> 
> ----------
> nosy: +r.david.murray
> 
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue24123>
> _______________________________________

----------
title: Python 2.7 Tutorial Conflicting behavior  with WeakValueDictionary. -> 
Python 2.7 Tutorial Conflicting behavior with WeakValueDictionary.

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24123>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to