diff options
author | Georg Brandl <georg@python.org> | 2005-07-02 19:07:30 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2005-07-02 19:07:30 (GMT) |
commit | 9a65d583ac454a09ccb0c8e42eb4c496f6185653 (patch) | |
tree | 0bad2bb033938d5340da075662df5c3326318af7 /Doc/lib | |
parent | f0af0e7a466797d9ed3fa7d635b9b1e91d5c2674 (diff) | |
download | cpython-9a65d583ac454a09ccb0c8e42eb4c496f6185653.zip cpython-9a65d583ac454a09ccb0c8e42eb4c496f6185653.tar.gz cpython-9a65d583ac454a09ccb0c8e42eb4c496f6185653.tar.bz2 |
Add doctest for examples in libweakref.tex to test_weakref.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libweakref.tex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/lib/libweakref.tex b/Doc/lib/libweakref.tex index 617540b..2f8ade0 100644 --- a/Doc/lib/libweakref.tex +++ b/Doc/lib/libweakref.tex @@ -10,6 +10,8 @@ \versionadded{2.1} +% When making changes to the examples in this file, be sure to update +% Lib/test/test_weakref.py::libreftest too! The \module{weakref} module allows the Python programmer to create \dfn{weak references} to objects. @@ -228,7 +230,7 @@ this pattern: o = r() if o is None: # referent has been garbage collected - print "Object has been allocated; can't frobnicate." + print "Object has been deallocated; can't frobnicate." else: print "Object is still live!" o.do_something_useful() @@ -265,7 +267,7 @@ class ExtendedRef(weakref.ref): """Return a pair containing the referent and the number of times the reference has been called. """ - ob = super(ExtendedRef, self)() + ob = super(ExtendedRef, self).__call__() if ob is not None: self.__counter += 1 ob = (ob, self.__counter) |