From 6430e92ad8fd0b5b02c09ea21dc2e18899bda7b4 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 31 Jul 2024 15:10:46 -0700 Subject: [PATCH] Use `get_module_name_if_available()` in detail/class.h --- include/pybind11/detail/class.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index 2df338555..b79c701c0 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -636,15 +636,7 @@ inline PyObject *make_new_python_type(const type_record &rec) { PyUnicode_FromFormat("%U.%U", rec.scope.attr("__qualname__").ptr(), name.ptr())); } - object module_; - if (rec.scope) { - if (hasattr(rec.scope, "__module__")) { - module_ = rec.scope.attr("__module__"); - } else if (hasattr(rec.scope, "__name__")) { - module_ = rec.scope.attr("__name__"); - } - } - + object module_ = get_module_name_if_available(rec.scope); const auto *full_name = c_str( #if !defined(PYPY_VERSION) module_ ? str(module_).cast() + "." + rec.name :