Commit 9d2ae85b authored by Stefan Behnel's avatar Stefan Behnel

Add more visible warnings to C-API functions that steal references of their arguments.

parent 84b6c4a3
......@@ -42,17 +42,19 @@ cdef extern from "Python.h":
int PyList_SetItem(object list, Py_ssize_t index, object item) except -1
# Set the item at index index in list to item. Return 0 on success
# or -1 on failure. Note: This function ``steals'' a reference to
# item and discards a reference to an item already in the list at
# the affected position.
# or -1 on failure.
#
# WARNING: This function _steals_ a reference to item and discards a
# reference to an item already in the list at the affected position.
void PyList_SET_ITEM(object list, Py_ssize_t i, object o)
# Macro form of PyList_SetItem() without error checking. This is
# normally only used to fill in new lists where there is no
# previous content. Note: This function ``steals'' a reference to
# item, and, unlike PyList_SetItem(), does not discard a reference
# to any item that it being replaced; any reference in list at
# position i will be *leaked*.
# previous content.
#
# WARNING: This function _steals_ a reference to item, and, unlike
# PyList_SetItem(), does not discard a reference to any item that
# it being replaced; any reference in list at position i will be *leaked*.
int PyList_Insert(object list, Py_ssize_t index, object item) except -1
# Insert the item item into list list in front of index
......
......@@ -191,9 +191,10 @@ cdef extern from "Python.h":
int PyModule_AddObject(object module, const char *name, object value) except -1
# Add an object to module as name. This is a convenience function
# which can be used from the module's initialization
# function. This steals a reference to value. Return -1 on error,
# 0 on success.
# which can be used from the module's initialization function.
# Return -1 on error, 0 on success.
#
# WARNING: This _steals_ a reference to value.
int PyModule_AddIntConstant(object module, const char *name, long value) except -1
# Add an integer constant to module as name. This convenience
......
......@@ -47,13 +47,15 @@ cdef extern from "Python.h":
int PyTuple_SetItem(object p, Py_ssize_t pos, object o) except -1
# Insert a reference to object o at position pos of the tuple
# pointed to by p. Return 0 on success. Note: This function
# ``steals'' a reference to o.
# pointed to by p. Return 0 on success.
#
# WARNING: This function _steals_ a reference to o.
void PyTuple_SET_ITEM(object p, Py_ssize_t pos, object o)
# Like PyTuple_SetItem(), but does no error checking, and should
# only be used to fill in brand new tuples. Note: This function
# ``steals'' a reference to o.
# only be used to fill in brand new tuples.
#
# WARNING: This function _steals_ a reference to o.
int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) except -1
# Can be used to resize a tuple. newsize will be the new length of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment