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 6 commits into
Conversation
Documentation build overview
17 files changed ·
|
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"?
| 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?
There was a problem hiding this comment.
I could, but I'm worried it would send the wrong message:
- We know that the result will always be a
bytesobject here, so it's not a great idea to encourage the user to do needless error checking in order to stay compatible with an API layer they haven't learned about yet. - It complicates the example, because it now needs a new error path with a
Py_DECREFin it.
| } | ||
|
|
||
| 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.
There was a problem hiding this comment.
The code and description here don't match PyUnicode_AsUTF8AndSize. It'd require some rewriting to be correct.
| *************************** | ||
|
|
||
| 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?
Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
Just by deleting the section? Or do you want me to do some refactoring? |
No description provided.