Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bf88b68f
Commit
bf88b68f
authored
Oct 05, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation for the public API for weak reference objects.
parent
f7f8cad5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
1 deletion
+70
-1
Doc/api/api.tex
Doc/api/api.tex
+70
-1
No files found.
Doc/api/api.tex
View file @
bf88b68f
...
...
@@ -1099,13 +1099,14 @@ completeness, here are all the variables:
\lineiii
{
PyExc
_
NotImplementedError
}{
\exception
{
NotImplementedError
}}{}
\lineiii
{
PyExc
_
OSError
}{
\exception
{
OSError
}}{}
\lineiii
{
PyExc
_
OverflowError
}{
\exception
{
OverflowError
}}{}
\lineiii
{
PyExc
_
ReferenceError
}{
\exception
{
ReferenceError
}}{
(2)
}
\lineiii
{
PyExc
_
RuntimeError
}{
\exception
{
RuntimeError
}}{}
\lineiii
{
PyExc
_
SyntaxError
}{
\exception
{
SyntaxError
}}{}
\lineiii
{
PyExc
_
SystemError
}{
\exception
{
SystemError
}}{}
\lineiii
{
PyExc
_
SystemExit
}{
\exception
{
SystemExit
}}{}
\lineiii
{
PyExc
_
TypeError
}{
\exception
{
TypeError
}}{}
\lineiii
{
PyExc
_
ValueError
}{
\exception
{
ValueError
}}{}
\lineiii
{
PyExc
_
WindowsError
}{
\exception
{
WindowsError
}}{
(
2
)
}
\lineiii
{
PyExc
_
WindowsError
}{
\exception
{
WindowsError
}}{
(
3
)
}
\lineiii
{
PyExc
_
ZeroDivisionError
}{
\exception
{
ZeroDivisionError
}}{}
\end{tableiii}
...
...
@@ -1116,6 +1117,9 @@ Notes:
This is a base class for other standard exceptions.
\item
[(2)]
This is the same as
\exception
{
weakref.ReferenceError
}
.
\item
[(3)]
Only defined on Windows; protect code that uses this by testing that
the preprocessor macro
\code
{
MS
_
WINDOWS
}
is defined.
\end{description}
...
...
@@ -4502,6 +4506,71 @@ returned.
\end{cfuncdesc}
\subsection
{
Weak Reference Objects
\label
{
weakref-objects
}}
Python supports
\emph
{
weak references
}
as first-class objects. There
are two specific object types which directly implement weak
references. The first is a simple reference object, and the second
acts as a proxy for the original object as much as it can.
\begin{cfuncdesc}
{
int
}{
PyWeakref
_
Check
}{
ob
}
Return true if
\var
{
ob
}
is either a reference or proxy object.
\versionadded
{
2.2
}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyWeakref
_
CheckRef
}{
ob
}
Return true if
\var
{
ob
}
is a reference object.
\versionadded
{
2.2
}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyWeakref
_
CheckProxy
}{
ob
}
Return true if
\var
{
ob
}
is a proxy object.
\versionadded
{
2.2
}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyWeakref
_
NewRef
}{
PyObject *ob,
PyObject *callback
}
Return a weak reference object for the object
\var
{
ob
}
. This will
always return a new reference, but is not guaranteed to create a new
object; an existing reference object may be returned. The second
parameter,
\var
{
callback
}
, can be a callable object that receives
notification when
\var
{
ob
}
is garbage collected; it should accept a
single paramter, which will be the weak reference object itself.
\var
{
callback
}
may also be
\code
{
None
}
or
\NULL
. If
\var
{
ob
}
is not a weakly-referencable object, or if
\var
{
callback
}
is not
callable,
\code
{
None
}
, or
\NULL
, this will return
\NULL
{}
and
raise
\exception
{
TypeError
}
.
\versionadded
{
2.2
}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyWeakref
_
NewProxy
}{
PyObject *ob,
PyObject *callback
}
Return a weak reference proxy object for the object
\var
{
ob
}
. This
will always return a new reference, but is not guaranteed to create
a new object; an existing proxy object may be returned. The second
parameter,
\var
{
callback
}
, can be a callable object that receives
notification when
\var
{
ob
}
is garbage collected; it should accept a
single paramter, which will be the weak reference object itself.
\var
{
callback
}
may also be
\code
{
None
}
or
\NULL
. If
\var
{
ob
}
is not
a weakly-referencable object, or if
\var
{
callback
}
is not callable,
\code
{
None
}
, or
\NULL
, this will return
\NULL
{}
and raise
\exception
{
TypeError
}
.
\versionadded
{
2.2
}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyWeakref
_
GetObject
}{
PyObject *ref
}
Returns the referenced object from a weak reference,
\var
{
ref
}
. If
the referent is no longer live, returns
\NULL
.
\versionadded
{
2.2
}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyWeakref
_
GET
_
OBJECT
}{
PyObject *ref
}
Similar to
\cfunction
{
PyWeakref
_
GetObject()
}
, but implemented as a
macro that does no error checking.
\versionadded
{
2.2
}
\end{cfuncdesc}
\subsection
{
CObjects
\label
{
cObjects
}}
\obindex
{
CObject
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment