Skip to content

Commit

Permalink
Temporary fix for the return value cast problem.
Browse files Browse the repository at this point in the history
pybind11::cast_error:
     return_value_policy = copy, but the object is non-copyable!
May be the same/related issue as described here:
     pybind#1241
  • Loading branch information
bbarcklay committed Feb 16, 2018
1 parent 2d0507d commit 338d615
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,14 @@ class type_caster_generic {
break;

case return_value_policy::copy:
if (copy_constructor)
if (copy_constructor) {
valueptr = copy_constructor(src);
else
throw cast_error("return_value_policy = copy, but the "
"object is non-copyable!");
wrapper->owned = true;
break;
wrapper->owned = true;
} else { // Instead of throwing an error, treat as if return_value_policy::reference.
valueptr = src;
wrapper->owned = false;
}
break;

case return_value_policy::move:
if (move_constructor)
Expand Down

0 comments on commit 338d615

Please sign in to comment.