File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,7 @@ struct string_caster {
435
435
auto nbytes = ssize_t (src.size () * sizeof (CharT));
436
436
handle s;
437
437
if (policy == return_value_policy::return_as_bytes) {
438
- s = PYBIND11_BYTES_FROM_STRING_AND_SIZE (buffer, nbytes);
438
+ s = PyBytes_FromStringAndSize (buffer, nbytes);
439
439
} else {
440
440
s = decode_utfN (buffer, nbytes);
441
441
}
Original file line number Diff line number Diff line change @@ -461,11 +461,13 @@ enum class return_value_policy : uint8_t {
461
461
return_value_policy::reference and the keep_alive call policy */
462
462
reference_internal,
463
463
464
- /* * Use this policy to make C++ functions return bytes to Python instead of
465
- str. This is useful when C++ function returns nested type of string,
466
- where we cannot apply `py::bytes` easily. Note that when C++ function
467
- returns string, we don't have to deal ownership for sure, because we
468
- are always copying the C++ string to a new Python str/bytes object.*/
464
+ /* * With this policy, C++ string types are converted to Python bytes,
465
+ instead of str. This is most useful when a C++ function returns a
466
+ container-like type with nested C++ string types, and py::bytes cannot
467
+ be applied easily. Note that this return_value_policy is not concerned
468
+ with lifetime/ownership semantics, like the other policies, but the
469
+ purpose of return_as_bytes is certain to be orthogonal, because C++
470
+ strings are always copied to Python bytes or str. */
469
471
return_as_bytes
470
472
};
471
473
You can’t perform that action at this time.
0 commit comments