Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
9d2ae85b
Commit
9d2ae85b
authored
May 07, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more visible warnings to C-API functions that steal references of their arguments.
parent
84b6c4a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
Cython/Includes/cpython/list.pxd
Cython/Includes/cpython/list.pxd
+9
-7
Cython/Includes/cpython/module.pxd
Cython/Includes/cpython/module.pxd
+4
-3
Cython/Includes/cpython/tuple.pxd
Cython/Includes/cpython/tuple.pxd
+6
-4
No files found.
Cython/Includes/cpython/list.pxd
View file @
9d2ae85b
...
@@ -42,17 +42,19 @@ cdef extern from "Python.h":
...
@@ -42,17 +42,19 @@ cdef extern from "Python.h":
int
PyList_SetItem
(
object
list
,
Py_ssize_t
index
,
object
item
)
except
-
1
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
# 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
# or -1 on failure.
# item and discards a reference to an item already in the list at
#
# the affected position.
# 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
)
void
PyList_SET_ITEM
(
object
list
,
Py_ssize_t
i
,
object
o
)
# Macro form of PyList_SetItem() without error checking. This is
# Macro form of PyList_SetItem() without error checking. This is
# normally only used to fill in new lists where there is no
# normally only used to fill in new lists where there is no
# previous content. Note: This function ``steals'' a reference to
# previous content.
# item, and, unlike PyList_SetItem(), does not discard a reference
#
# to any item that it being replaced; any reference in list at
# WARNING: This function _steals_ a reference to item, and, unlike
# position i will be *leaked*.
# 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
int
PyList_Insert
(
object
list
,
Py_ssize_t
index
,
object
item
)
except
-
1
# Insert the item item into list list in front of index
# Insert the item item into list list in front of index
...
...
Cython/Includes/cpython/module.pxd
View file @
9d2ae85b
...
@@ -191,9 +191,10 @@ cdef extern from "Python.h":
...
@@ -191,9 +191,10 @@ cdef extern from "Python.h":
int
PyModule_AddObject
(
object
module
,
const
char
*
name
,
object
value
)
except
-
1
int
PyModule_AddObject
(
object
module
,
const
char
*
name
,
object
value
)
except
-
1
# Add an object to module as name. This is a convenience function
# Add an object to module as name. This is a convenience function
# which can be used from the module's initialization
# which can be used from the module's initialization function.
# function. This steals a reference to value. Return -1 on error,
# Return -1 on error, 0 on success.
# 0 on success.
#
# WARNING: This _steals_ a reference to value.
int
PyModule_AddIntConstant
(
object
module
,
const
char
*
name
,
long
value
)
except
-
1
int
PyModule_AddIntConstant
(
object
module
,
const
char
*
name
,
long
value
)
except
-
1
# Add an integer constant to module as name. This convenience
# Add an integer constant to module as name. This convenience
...
...
Cython/Includes/cpython/tuple.pxd
View file @
9d2ae85b
...
@@ -47,13 +47,15 @@ cdef extern from "Python.h":
...
@@ -47,13 +47,15 @@ cdef extern from "Python.h":
int
PyTuple_SetItem
(
object
p
,
Py_ssize_t
pos
,
object
o
)
except
-
1
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
# Insert a reference to object o at position pos of the tuple
# pointed to by p. Return 0 on success. Note: This function
# pointed to by p. Return 0 on success.
# ``steals'' a reference to o.
#
# WARNING: This function _steals_ a reference to o.
void
PyTuple_SET_ITEM
(
object
p
,
Py_ssize_t
pos
,
object
o
)
void
PyTuple_SET_ITEM
(
object
p
,
Py_ssize_t
pos
,
object
o
)
# Like PyTuple_SetItem(), but does no error checking, and should
# Like PyTuple_SetItem(), but does no error checking, and should
# only be used to fill in brand new tuples. Note: This function
# only be used to fill in brand new tuples.
# ``steals'' a reference to o.
#
# WARNING: This function _steals_ a reference to o.
int
_PyTuple_Resize
(
PyObject
**
p
,
Py_ssize_t
newsize
)
except
-
1
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
# Can be used to resize a tuple. newsize will be the new length of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment