mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-11 08:50:31 +00:00
Fix a reference leak in the number converter (#1078)
Fixes #1075. `PyNumber_Float()` and `PyNumber_Long()` return new references.
This commit is contained in:
committed by
Wenzel Jakob
parent
7b1de1e551
commit
953d2422b3
@@ -964,9 +964,9 @@ public:
|
||||
);
|
||||
PyErr_Clear();
|
||||
if (type_error && convert && PyNumber_Check(src.ptr())) {
|
||||
auto tmp = reinterpret_borrow<object>(std::is_floating_point<T>::value
|
||||
? PyNumber_Float(src.ptr())
|
||||
: PyNumber_Long(src.ptr()));
|
||||
auto tmp = reinterpret_steal<object>(std::is_floating_point<T>::value
|
||||
? PyNumber_Float(src.ptr())
|
||||
: PyNumber_Long(src.ptr()));
|
||||
PyErr_Clear();
|
||||
return load(tmp, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user