Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
c78dfe69
Unverified
Commit
c78dfe69
authored
Oct 03, 2022
by
Aaron Gokaslan
Committed by
GitHub
Oct 03, 2022
Browse files
bugfix: Add error checking to list append and insert (#4208)
parent
da8c730a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+9
-3
No files found.
include/pybind11/pytypes.h
View file @
c78dfe69
...
...
@@ -2022,14 +2022,20 @@ public:
detail
::
list_iterator
end
()
const
{
return
{
*
this
,
PyList_GET_SIZE
(
m_ptr
)};
}
template
<
typename
T
>
void
append
(
T
&&
val
)
/* py-non-const */
{
PyList_Append
(
m_ptr
,
detail
::
object_or_cast
(
std
::
forward
<
T
>
(
val
)).
ptr
());
if
(
PyList_Append
(
m_ptr
,
detail
::
object_or_cast
(
std
::
forward
<
T
>
(
val
)).
ptr
())
!=
0
)
{
throw
error_already_set
();
}
}
template
<
typename
IdxType
,
typename
ValType
,
detail
::
enable_if_t
<
std
::
is_integral
<
IdxType
>
::
value
,
int
>
=
0
>
void
insert
(
const
IdxType
&
index
,
ValType
&&
val
)
/* py-non-const */
{
PyList_Insert
(
m_ptr
,
ssize_t_cast
(
index
),
detail
::
object_or_cast
(
std
::
forward
<
ValType
>
(
val
)).
ptr
());
if
(
PyList_Insert
(
m_ptr
,
ssize_t_cast
(
index
),
detail
::
object_or_cast
(
std
::
forward
<
ValType
>
(
val
)).
ptr
())
!=
0
)
{
throw
error_already_set
();
}
}
};
...
...
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