mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-21 07:59:17 +00:00
pull in get_module_name_if_available()
(pytypes.h)
This commit is contained in:
parent
cae3cf99b6
commit
e6c74dfef4
@ -2604,5 +2604,18 @@ PYBIND11_MATH_OPERATOR_BINARY_INPLACE(operator>>=, PyNumber_InPlaceRshift)
|
|||||||
#undef PYBIND11_MATH_OPERATOR_BINARY
|
#undef PYBIND11_MATH_OPERATOR_BINARY
|
||||||
#undef PYBIND11_MATH_OPERATOR_BINARY_INPLACE
|
#undef PYBIND11_MATH_OPERATOR_BINARY_INPLACE
|
||||||
|
|
||||||
|
// Meant to return a Python str, but this is not checked.
|
||||||
|
inline object get_module_name_if_available(handle scope) {
|
||||||
|
if (scope) {
|
||||||
|
if (hasattr(scope, "__module__")) {
|
||||||
|
return scope.attr("__module__");
|
||||||
|
}
|
||||||
|
if (hasattr(scope, "__name__")) {
|
||||||
|
return scope.attr("__name__");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return object();
|
||||||
|
}
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(detail)
|
PYBIND11_NAMESPACE_END(detail)
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||||
|
Loading…
Reference in New Issue
Block a user