Created
December 30, 2015 21:40
-
-
Save OrangeTux/df1c57ab660e79e9d3db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new C tuple object of size 3. | |
typle = PyTuple_New(3) | |
// Manually check if tuple is created correctly. | |
if (tuple == NULL) | |
return NULL; | |
for (i=0; i<3; i++) { | |
// Create Python integer. | |
item = PyInt_FromLong(42); | |
// Again, manually check if everything went well. | |
// If not, decrease reference counter of tulpe object. | |
if (item == NULL) { | |
// Decrease references counter to tuple object. | |
Py_DECREF(tuple); | |
return NULL; | |
} | |
// Set i-th item of tuple to 42. | |
PyTuple_SET_ITEM(tuple, i, item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment