Skip to content

Add a new return value policy _clif_automatic #4343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,16 @@ enum class return_value_policy : uint8_t {
but the purpose of _return_as_bytes is certain to be orthogonal, because
C++ strings are always copied to Python `bytes` or `str`.
NOTE: This policy is NOT available on master. */
_return_as_bytes
_return_as_bytes,

/** This policy should only be used by PyCLIF to automatically select a
return value policy. Legacy PyCLIF automatically decides object lifetime
management based on their properties:
https://github.com/google/clif/tree/main/clif/python#pointers-references-and-object-ownership
With this policy, the return value policy selection is consistent with
legacy PyCLIF.
NOTE: This policy is NOT available on master. */
_clif_automatic
};

PYBIND11_NAMESPACE_BEGIN(detail)
Expand Down
1 change: 1 addition & 0 deletions include/pybind11/detail/smart_holder_type_casters.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
break;
case return_value_policy::reference_internal:
case return_value_policy::_return_as_bytes:
case return_value_policy::_clif_automatic:
break;
}
if (!src) {
Expand Down