]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Minor C API documentation improvements. (GH-17698)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 25 Dec 2019 04:35:20 +0000 (20:35 -0800)
committerBenjamin Peterson <benjamin@python.org>
Wed, 25 Dec 2019 04:35:20 +0000 (22:35 -0600)
The added parentheses around the PyIter_Next assignment suppress the following warning which gcc throws without:
```
warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
```
The other change is a typo fix
(cherry picked from commit 5c7ed7550ec2da16d7679e538fcd7c1a5631811f)

Co-authored-by: William Ayd <william.ayd@icloud.com>
Doc/c-api/iter.rst
Doc/includes/custom.c

index 62ca082713b6844c40d740b1ea4835f1161ddbeb..6507da9c7f0a51d9649523bed03964eaa7e634f9 100644 (file)
@@ -29,7 +29,7 @@ something like this::
        /* propagate error */
    }
 
-   while (item = PyIter_Next(iterator)) {
+   while ((item = PyIter_Next(iterator))) {
        /* do something with item */
        ...
        /* release reference when done */
index bda32e2ad81d464c54aac5a442346ce95691e03e..f361baf830dd1b3c9a0b644479683b4f884affd5 100644 (file)
@@ -37,7 +37,7 @@ PyInit_custom(void)
     Py_INCREF(&CustomType);
     if (PyModule_AddObject(m, "Custom", (PyObject *) &CustomType) < 0) {
         Py_DECREF(&CustomType);
-        PY_DECREF(m);
+        Py_DECREF(m);
         return NULL;
     }