We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a5729a3 commit 5febe3aCopy full SHA for 5febe3a
include/pybind11/pybind11.h
@@ -256,6 +256,9 @@ class cpp_function : public function {
256
/// Register a function call with Python (generic non-templated code goes here)
257
void initialize_generic(unique_function_record &&unique_rec, const char *text,
258
const std::type_info *const *types, size_t args) {
259
+ // Do NOT receive `unique_rec` by value. If this function fails to move the unique_ptr, then
260
+ // we do not want this to destuct the pointer. `initialize` (the caller) still relies on the
261
+ // pointee being alive after this call. Only move if a `capsule` is going to keep it alive.
262
auto rec = unique_rec.get();
263
264
// Keep track of strdup'ed strings, and clean them up as long as the function's capsule
0 commit comments