Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(89522)

Unified Diff: Doc/howto/cporting.rst

Issue 24937: Multiple problems in getters & setters in capsulethunk.h
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
index d7a7086..7ab4424 100644
--- a/Doc/howto/cporting.rst
+++ b/Doc/howto/cporting.rst
@@ -207,45 +207,25 @@ If you're currently using CObjects, and you want to migrate to 3.1 or newer,
you'll need to switch to Capsules.
:c:type:`CObject` was deprecated in 3.1 and 2.7 and completely removed in
Python 3.2. If you only support 2.7, or 3.1 and above, you
-can simply switch to :c:type:`Capsule`. If you need to support Python 3.0,
-or versions of Python earlier than 2.7,
+can simply switch to :c:type:`Capsule`.
+
+If you need to support versions of Python earlier than 2.7, or Python 3.0,
you'll have to support both CObjects and Capsules.
(Note that Python 3.0 is no longer supported, and it is not recommended
for production use.)
-The following example header file :file:`capsulethunk.h` may
-solve the problem for you. Simply write your code against the
-:c:type:`Capsule` API and include this header file after
-:file:`Python.h`. Your code will automatically use Capsules
-in versions of Python with Capsules, and switch to CObjects
-when Capsules are unavailable.
-
-:file:`capsulethunk.h` simulates Capsules using CObjects. However,
-:c:type:`CObject` provides no place to store the capsule's "name". As a
-result the simulated :c:type:`Capsule` objects created by :file:`capsulethunk.h`
-behave slightly differently from real Capsules. Specifically:
-
- * The name parameter passed in to :c:func:`PyCapsule_New` is ignored.
-
- * The name parameter passed in to :c:func:`PyCapsule_IsValid` and
- :c:func:`PyCapsule_GetPointer` is ignored, and no error checking
- of the name is performed.
-
- * :c:func:`PyCapsule_GetName` always returns NULL.
-
- * :c:func:`PyCapsule_SetName` always raises an exception and
- returns failure. (Since there's no way to store a name
- in a CObject, noisy failure of :c:func:`PyCapsule_SetName`
- was deemed preferable to silent failure here. If this is
- inconvenient, feel free to modify your local
- copy as you see fit.)
-
-You can find :file:`capsulethunk.h` in the Python source distribution
-as :source:`Doc/includes/capsulethunk.h`. We also include it here for
-your convenience:
+The ``py3c`` project maintains an example header file ``capsulethunk.h``
+that can may solve the problem for you. It implements the Capsule API in terms
+of CObject. Simply write your code against the :c:type:`Capsule` API (with
+some limitations) and include this header file after :file:`Python.h`.
+Your code will automatically use Capsules in versions of Python with Capsules,
+and switch to CObjects when Capsules are unavailable.
-.. literalinclude:: ../includes/capsulethunk.h
+You can find the `capsulethunk.h file`_ and its `documentation`_ in the
+``py3c`` project.
+.. _capsulethunk.h file: https://github.com/encukou/py3c/blob/master/include/py3c/capsulethunk.h
+.. _documentation: http://py3c.readthedocs.org/en/latest/capsulethunk.html
Other options
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+