Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
251516bc
Commit
251516bc
authored
Oct 21, 2022
by
Aaron Gokaslan
Committed by
Henry Schreiner
Oct 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup casters to release none() to avoid ref counting (#4269)
parent
a8f21107
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
include/pybind11/cast.h
+3
-3
include/pybind11/functional.h
+1
-1
include/pybind11/stl.h
+1
-1
No files found.
include/pybind11/cast.h
View file @
251516bc
...
...
@@ -248,7 +248,7 @@ public:
return
false
;
}
static
handle
cast
(
T
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
return
none
().
inc_ref
();
return
none
().
release
();
}
PYBIND11_TYPE_CASTER
(
T
,
const_name
(
"None"
));
};
...
...
@@ -291,7 +291,7 @@ public:
if
(
ptr
)
{
return
capsule
(
ptr
).
release
();
}
return
none
().
inc_ref
();
return
none
().
release
();
}
template
<
typename
T
>
...
...
@@ -537,7 +537,7 @@ public:
static
handle
cast
(
const
CharT
*
src
,
return_value_policy
policy
,
handle
parent
)
{
if
(
src
==
nullptr
)
{
return
pybind11
::
none
().
inc_ref
();
return
pybind11
::
none
().
release
();
}
return
StringCaster
::
cast
(
StringType
(
src
),
policy
,
parent
);
}
...
...
include/pybind11/functional.h
View file @
251516bc
...
...
@@ -110,7 +110,7 @@ public:
template
<
typename
Func
>
static
handle
cast
(
Func
&&
f_
,
return_value_policy
policy
,
handle
/* parent */
)
{
if
(
!
f_
)
{
return
none
().
inc_ref
();
return
none
().
release
();
}
auto
result
=
f_
.
template
target
<
function_type
>
();
...
...
include/pybind11/stl.h
View file @
251516bc
...
...
@@ -311,7 +311,7 @@ struct optional_caster {
template
<
typename
T
>
static
handle
cast
(
T
&&
src
,
return_value_policy
policy
,
handle
parent
)
{
if
(
!
src
)
{
return
none
().
inc_ref
();
return
none
().
release
();
}
if
(
!
std
::
is_lvalue_reference
<
T
>::
value
)
{
policy
=
return_value_policy_override
<
Value
>::
policy
(
policy
);
...
...
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