Add a new C API tutorial for reference counting and error handling#150090
Add a new C API tutorial for reference counting and error handling#150090ZeroIntensity wants to merge 4 commits into
Conversation
Documentation build overview
|
encukou
left a comment
There was a problem hiding this comment.
These look good, but now for the hard part: Could you remove the topics covered here from "Assorted topics"?
| the caller. This is also called "stealing" a reference (so, in the above | ||
| example, the caller steals our strong reference to ``result``). |
There was a problem hiding this comment.
I'd rather not use the term "stealing" for cases where transferring ownership is the normal thing to do.
How about this?
| the caller. This is also called "stealing" a reference (so, in the above | |
| example, the caller steals our strong reference to ``result``). | |
| the caller. | |
| The caller is now responsible for making sure :c:macro:`Py_DECREF` is called -- | |
| either by calling it, or by delegating this responsibility. |
| if (bytes == NULL) { | ||
| return NULL; | ||
| } | ||
| const char *command = PyBytes_AS_STRING(bytes); |
There was a problem hiding this comment.
Could you use PyBytes_AsString, to stay within the Limited API?
| } | ||
|
|
||
| If :c:func:`PyUnicode_AsUTF8AndSize` is successful, *command* will point to the | ||
| If :c:func:`PyUnicode_AsUTF8` is successful, *command* will point to the |
There was a problem hiding this comment.
Please keep the Stable ABI function here.
| ======================= | ||
|
|
||
| Python has a thread-local indicator for the state of the current exception. | ||
| This indicator is just a ``PyObject *`` referencing an instance of |
There was a problem hiding this comment.
| This indicator is just a ``PyObject *`` referencing an instance of | |
| This indicator is a ``PyObject *`` referencing an instance of |
| *************************** | ||
|
|
||
| This chapter covers the details about how Python's C API expresses errors | ||
| and how to interact with Python exceptions. |
There was a problem hiding this comment.
Could you mention that the tutorial builds on the module from "Your first C API extension module"?
| return NULL; | ||
| } | ||
|
|
||
| // Py_NewRef() is just a shorthand for Py_INCREF() with an expression |
There was a problem hiding this comment.
Would it make sense to introduce Py_NewRef in the refcounting chapter?
No description provided.