mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
fixed Py_None reference couting
This commit is contained in:
parent
5812d64ba2
commit
9d7f7a38a7
@ -185,7 +185,7 @@ public:
|
||||
const void *existing_holder = nullptr) {
|
||||
void *src = const_cast<void *>(_src);
|
||||
if (src == nullptr)
|
||||
return none();
|
||||
return none().inc_ref();
|
||||
|
||||
auto &internals = get_internals();
|
||||
|
||||
@ -414,7 +414,7 @@ template <> class type_caster<void_type> {
|
||||
public:
|
||||
bool load(handle, bool) { return false; }
|
||||
static handle cast(void_type, return_value_policy /* policy */, handle /* parent */) {
|
||||
return none();
|
||||
return none().inc_ref();
|
||||
}
|
||||
PYBIND11_TYPE_CASTER(void_type, _("None"));
|
||||
};
|
||||
@ -452,7 +452,7 @@ public:
|
||||
if (ptr)
|
||||
return capsule(ptr).release();
|
||||
else
|
||||
return none();
|
||||
return none().inc_ref();
|
||||
}
|
||||
|
||||
template <typename T> using cast_op_type = void*&;
|
||||
@ -569,7 +569,7 @@ public:
|
||||
}
|
||||
|
||||
static handle cast(const char *src, return_value_policy /* policy */, handle /* parent */) {
|
||||
if (src == nullptr) return none();
|
||||
if (src == nullptr) return none().inc_ref();
|
||||
return PyUnicode_FromString(src);
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ public:
|
||||
}
|
||||
|
||||
static handle cast(const wchar_t *src, return_value_policy /* policy */, handle /* parent */) {
|
||||
if (src == nullptr) return none();
|
||||
if (src == nullptr) return none().inc_ref();
|
||||
return PyUnicode_FromWideChar(src, (ssize_t) wcslen(src));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
template <typename Func>
|
||||
static handle cast(Func &&f_, return_value_policy policy, handle /* parent */) {
|
||||
if (!f_)
|
||||
return none();
|
||||
return none().inc_ref();
|
||||
|
||||
auto result = f_.template target<Return (*)(Args...)>();
|
||||
if (result)
|
||||
|
Loading…
Reference in New Issue
Block a user