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
07446781
Commit
07446781
authored
Dec 17, 2010
by
Daniel Stutzbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 8753: Added documentation for Py_ReprEntr and Py_ReprLeave.
parent
18af5a6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
Doc/c-api/exceptions.rst
Doc/c-api/exceptions.rst
+29
-0
No files found.
Doc/c-api/exceptions.rst
View file @
07446781
...
...
@@ -533,6 +533,35 @@ recursion depth automatically).
Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each
*successful* invocation of :c:func:`Py_EnterRecursiveCall`.
Properly implementing :attr:`tp_repr` for container types requires
special recursion handling. In addition to protecting the stack,
:attr:`tp_repr` also needs to track objects to prevent cycles. The
following two functions facilitate this functionality. Effectively,
these are the C equivalent to :func:`reprlib.recursive_repr`.
.. c:function:: int Py_ReprEntr(PyObject *object)
Called at the beginning of the :attr:`tp_repr` implementation to
detect cycles.
If the object has already been processed, the function returns a
positive integer. In that case the :attr:`tp_repr` implementation
should return a string object indicating a cycle. As examples,
:class:`dict` objects return ``{...}`` and :class:`list` objects
return ``[...]``.
The function will return a negative integer if the recursion limit
is reached. In that case the :attr:`tp_repr` implementation should
typically return ``NULL``.
Otherwise, the function returns zero and the :attr:`tp_repr`
implementation can continue normally.
.. c:function:: void Py_ReprLeave(PyObject *object)
Ends a :c:func:`Py_ReprEntr`. Must be called once for each
invocation of :c:func:`Py_ReprEntr` that returns zero.
.. _standardexceptions:
...
...
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