Commit 5d548796 authored by Fred Drake's avatar Fred Drake

Fix some of the example code; the reference objects do not support a

get() method; just calling them is sufficient.  (There was a get() method
for this in an early version of the implementation.)

Reported by Mats Wichmann.
parent f980301b
...@@ -151,12 +151,12 @@ None ...@@ -151,12 +151,12 @@ None
\end{verbatim} \end{verbatim}
Testing that a weak reference object is still live should be done Testing that a weak reference object is still live should be done
using the expression \code{\var{ref}.get() is not None}. Normally, using the expression \code{\var{ref}() is not None}. Normally,
application code that needs to use a reference object should follow application code that needs to use a reference object should follow
this pattern: this pattern:
\begin{verbatim} \begin{verbatim}
o = ref.get() o = ref()
if o is None: if o is None:
# referent has been garbage collected # referent has been garbage collected
print "Object has been allocated; can't frobnicate." print "Object has been allocated; can't frobnicate."
...@@ -190,7 +190,7 @@ def remember(obj): ...@@ -190,7 +190,7 @@ def remember(obj):
_id2obj_dict[id(obj)] = obj _id2obj_dict[id(obj)] = obj
def id2obj(id): def id2obj(id):
return _id2obj_dict.get(id) return _id2obj_dict(id)
\end{verbatim} \end{verbatim}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment