[pypy-svn] r58683 - in pypy/branch/2.5-merge/pypy/module/itertools: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Oct 6 18:59:07 CEST 2008
Author: arigo
Date: Mon Oct 6 18:59:06 2008
New Revision: 58683
Modified:
pypy/branch/2.5-merge/pypy/module/itertools/interp_itertools.py
pypy/branch/2.5-merge/pypy/module/itertools/test/test_itertools.py
Log:
(iko, arigo)
Make itertools.tee() results weakrefable.
Modified: pypy/branch/2.5-merge/pypy/module/itertools/interp_itertools.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/itertools/interp_itertools.py (original)
+++ pypy/branch/2.5-merge/pypy/module/itertools/interp_itertools.py Mon Oct 6 18:59:06 2008
@@ -1,6 +1,6 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.error import OperationError
-from pypy.interpreter.typedef import TypeDef
+from pypy.interpreter.typedef import TypeDef, make_weakref_descr
from pypy.interpreter.gateway import interp2app, ObjSpace, W_Root
from pypy.rlib.rarithmetic import ovfcheck
@@ -726,7 +726,9 @@
W_TeeIterable.typedef = TypeDef(
'_tee',
__iter__ = interp2app(W_TeeIterable.iter_w, unwrap_spec=['self']),
- next = interp2app(W_TeeIterable.next_w, unwrap_spec=['self']))
+ next = interp2app(W_TeeIterable.next_w, unwrap_spec=['self']),
+ __weakref__ = make_weakref_descr(W_TeeIterable),
+ )
W_TeeIterable.typedef.acceptable_as_base_class = False
Modified: pypy/branch/2.5-merge/pypy/module/itertools/test/test_itertools.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/itertools/test/test_itertools.py (original)
+++ pypy/branch/2.5-merge/pypy/module/itertools/test/test_itertools.py Mon Oct 6 18:59:06 2008
@@ -604,3 +604,10 @@
]
for method in methods:
assert method.__doc__
+
+ def test_tee_weakrefable(self):
+ import itertools, weakref
+
+ a, b = itertools.tee(iter('abc'))
+ ref = weakref.ref(b)
+ assert ref() is b
More information about the Pypy-commit
mailing list