_ZN8pybind1110make_tupleILNS_19return_value_policyE1EJRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS_4noneEEEENS_6typing5TupleIJDpT0_EEEDpOSE_:
 2004|  2.39k|typing::Tuple<Args...> make_tuple(Args &&...args_) {
 2005|  2.39k|    constexpr size_t size = sizeof...(Args);
 2006|  2.39k|    std::array<object, size> args{{reinterpret_steal<object>(
 2007|  2.39k|        detail::make_caster<Args>::cast(std::forward<Args>(args_), policy, nullptr))...}};
 2008|  7.09k|    for (size_t i = 0; i < args.size(); i++) {
  ------------------
  |  Branch (2008:24): [True: 4.69k, False: 2.39k]
  ------------------
 2009|  4.69k|        if (!args[i]) {
  ------------------
  |  Branch (2009:13): [True: 0, False: 4.69k]
  ------------------
 2010|      0|#if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
 2011|      0|            throw cast_error_unable_to_convert_call_arg(std::to_string(i));
 2012|       |#else
 2013|       |            std::array<std::string, size> argtypes{{type_id<Args>()...}};
 2014|       |            throw cast_error_unable_to_convert_call_arg(std::to_string(i), argtypes[i]);
 2015|       |#endif
 2016|      0|        }
 2017|  4.69k|    }
 2018|  2.39k|    tuple result(size);
 2019|  2.39k|    int counter = 0;
 2020|  4.69k|    for (auto &arg_value : args) {
  ------------------
  |  Branch (2020:26): [True: 4.69k, False: 2.39k]
  ------------------
 2021|  4.69k|        detail::tuple_set_item(result.ptr(), counter++, arg_value.release().ptr());
 2022|  4.69k|    }
 2023|  2.39k|    PYBIND11_WARNING_PUSH
 2024|       |#ifdef PYBIND11_DETECTED_CLANG_WITH_MISLEADING_CALL_STD_MOVE_EXPLICITLY_WARNING
 2025|       |    PYBIND11_WARNING_DISABLE_CLANG("-Wreturn-std-move")
 2026|       |#endif
 2027|  2.39k|    return result;
 2028|  2.39k|    PYBIND11_WARNING_POP
 2029|  2.39k|}
_ZN8pybind116detail13string_casterINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEELb0EE4castERKS8_NS_19return_value_policyENS_6handleE:
  578|  4.74k|    cast(const StringType &src, return_value_policy /* policy */, handle /* parent */) {
  579|  4.74k|        const char *buffer = reinterpret_cast<const char *>(src.data());
  580|  4.74k|        auto nbytes = ssize_t(src.size() * sizeof(CharT));
  581|  4.74k|        handle s = decode_utfN(buffer, nbytes);
  582|  4.74k|        if (!s) {
  ------------------
  |  Branch (582:13): [True: 51, False: 4.69k]
  ------------------
  583|     51|            throw error_already_set();
  584|     51|        }
  585|  4.69k|        return s;
  586|  4.74k|    }
_ZN8pybind116detail13string_casterINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEELb0EE11decode_utfNEPKcl:
  591|  4.74k|    static handle decode_utfN(const char *buffer, ssize_t nbytes) {
  592|  4.74k|#if !defined(PYPY_VERSION)
  593|  4.74k|        return UTF_N == 8    ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr)
  ------------------
  |  Branch (593:16): [True: 4.74k, Folded]
  ------------------
  594|  4.74k|               : UTF_N == 16 ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr)
  ------------------
  |  Branch (594:18): [Folded, False: 0]
  ------------------
  595|      0|                             : PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr);
  596|       |#else
  597|       |        // PyPy segfaults when on PyUnicode_DecodeUTF16 (and possibly on PyUnicode_DecodeUTF32 as
  598|       |        // well), so bypass the whole thing by just passing the encoding as a string value, which
  599|       |        // works properly:
  600|       |        return PyUnicode_Decode(buffer,
  601|       |                                nbytes,
  602|       |                                UTF_N == 8    ? "utf-8"
  603|       |                                : UTF_N == 16 ? "utf-16"
  604|       |                                              : "utf-32",
  605|       |                                nullptr);
  606|       |#endif
  607|  4.74k|    }
_ZN8pybind116detail15pyobject_casterINS_4noneEE4castERKNS_6handleENS_19return_value_policyES4_:
 1589|  2.34k|    static handle cast(const handle &src, return_value_policy /* policy */, handle /* parent */) {
 1590|  2.34k|        return src.inc_ref();
 1591|  2.34k|    }
_ZNK8pybind116detail10object_apiINS_6handleEEclILNS_19return_value_policyE1EJRKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEEENS_6objectEDpOT0_:
 2473|  2.34k|object object_api<Derived>::operator()(Args &&...args) const {
 2474|       |#if !defined(NDEBUG) && !defined(Py_LIMITED_API) // PyGILState_Check: not in the stable ABI
 2475|       |    if (!PyGILState_Check()) {
 2476|       |        pybind11_fail("pybind11::object_api<>::operator() PyGILState_Check() failure.");
 2477|       |    }
 2478|       |#endif
 2479|  2.34k|    return detail::collect_arguments<policy>(std::forward<Args>(args)...).call(derived().ptr());
 2480|  2.34k|}
_ZN8pybind116detail17collect_argumentsILNS_19return_value_policyE1EJRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEENS0_19unpacking_collectorIXT_EEEDpOT0_:
 2460|  2.34k|unpacking_collector<policy> collect_arguments(Args &&...args) {
 2461|       |    // Following argument order rules for generalized unpacking according to PEP 448
 2462|  2.34k|    static_assert(
 2463|  2.34k|        constexpr_last<is_positional, Args...>() < constexpr_first<is_keyword_or_ds, Args...>(),
 2464|  2.34k|        "Invalid function call: positional args must precede keywords and */** unpacking;");
 2465|  2.34k|    static_assert(constexpr_last<is_s_unpacking, Args...>()
 2466|  2.34k|                      < constexpr_first<is_ds_unpacking, Args...>(),
 2467|  2.34k|                  "Invalid function call: * unpacking must precede ** unpacking");
 2468|  2.34k|    return unpacking_collector<policy>(std::forward<Args>(args)...);
 2469|  2.34k|}
_ZN8pybind116detail19unpacking_collectorILNS_19return_value_policyE1EEC2IJRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEEEEDpOT_:
 2286|  2.34k|        : m_names(reinterpret_steal<tuple>(
 2287|  2.34k|              handle())) // initialize to null to avoid useless allocation of 0-length tuple
 2288|  2.34k|    {
 2289|       |        /*
 2290|       |        Python can sometimes utilize an extra space before the arguments to prepend `self`.
 2291|       |        This is important enough that there is a special flag for it:
 2292|       |        PY_VECTORCALL_ARGUMENTS_OFFSET.
 2293|       |        All we have to do is allocate an extra space at the beginning of this array, and set the
 2294|       |        flag. Note that the extra space is not passed directly in to vectorcall.
 2295|       |        */
 2296|  2.34k|        m_args.reserve(sizeof...(values) + 1);
 2297|  2.34k|        m_args.push_back_null();
 2298|       |
 2299|  2.34k|        if (args_has_keyword_or_ds<Ts...>()) {
  ------------------
  |  Branch (2299:13): [Folded, False: 2.34k]
  ------------------
 2300|      0|            list names_list;
 2301|       |
 2302|       |            // collect_arguments guarantees this can't be constructed with kwargs before the last
 2303|       |            // positional so we don't need to worry about Ts... being in anything but normal python
 2304|       |            // order.
 2305|      0|            using expander = int[];
 2306|      0|            (void) expander{0, (process(names_list, std::forward<Ts>(values)), 0)...};
 2307|       |
 2308|      0|            m_names = reinterpret_steal<tuple>(PyList_AsTuple(names_list.ptr()));
 2309|  2.34k|        } else {
 2310|  2.34k|            auto not_used
 2311|  2.34k|                = reinterpret_steal<list>(handle()); // initialize as null (to avoid an allocation)
 2312|       |
 2313|  2.34k|            using expander = int[];
 2314|  2.34k|            (void) expander{0, (process(not_used, std::forward<Ts>(values)), 0)...};
 2315|  2.34k|        }
 2316|  2.34k|    }
_ZN8pybind116detail19unpacking_collectorILNS_19return_value_policyE1EE7processIRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEEEvRNS_4listEOT_:
 2359|  2.34k|    void process(list & /*names_list*/, T &&x) {
 2360|  2.34k|        handle h = detail::make_caster<T>::cast(std::forward<T>(x), policy, {});
 2361|  2.34k|        if (!h) {
  ------------------
  |  Branch (2361:13): [True: 0, False: 2.34k]
  ------------------
 2362|      0|#if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
 2363|      0|            throw cast_error_unable_to_convert_call_arg(std::to_string(m_args.size() - 1));
 2364|       |#else
 2365|       |            throw cast_error_unable_to_convert_call_arg(std::to_string(m_args.size() - 1),
 2366|       |                                                        type_id<T>());
 2367|       |#endif
 2368|      0|        }
 2369|  2.34k|        m_args.push_back_steal(h.ptr()); // cast returns a new reference
 2370|  2.34k|    }
_ZNK8pybind116detail19unpacking_collectorILNS_19return_value_policyE1EE4callEP7_object:
 2319|  2.35k|    object call(PyObject *ptr) const {
 2320|  2.35k|        size_t nargs = m_args.size() - 1; // -1 for PY_VECTORCALL_ARGUMENTS_OFFSET (see ctor)
 2321|  2.35k|        if (m_names) {
  ------------------
  |  Branch (2321:13): [True: 0, False: 2.35k]
  ------------------
 2322|      0|            nargs -= m_names.size();
 2323|      0|        }
 2324|  2.35k|        PyObject *result = PyObject_Vectorcall(
 2325|  2.35k|            ptr, m_args.data() + 1, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, m_names.ptr());
 2326|  2.35k|        if (!result) {
  ------------------
  |  Branch (2326:13): [True: 2.33k, False: 15]
  ------------------
 2327|  2.33k|            throw error_already_set();
 2328|  2.33k|        }
 2329|     15|        return reinterpret_steal<object>(result);
 2330|  2.35k|    }
_ZNK8pybind116detail10object_apiINS0_8accessorINS0_17accessor_policies8str_attrEEEEclILNS_19return_value_policyE1EJEEENS_6objectEDpOT0_:
 2473|     13|object object_api<Derived>::operator()(Args &&...args) const {
 2474|       |#if !defined(NDEBUG) && !defined(Py_LIMITED_API) // PyGILState_Check: not in the stable ABI
 2475|       |    if (!PyGILState_Check()) {
 2476|       |        pybind11_fail("pybind11::object_api<>::operator() PyGILState_Check() failure.");
 2477|       |    }
 2478|       |#endif
 2479|     13|    return detail::collect_arguments<policy>(std::forward<Args>(args)...).call(derived().ptr());
 2480|     13|}
_ZN8pybind116detail17collect_argumentsILNS_19return_value_policyE1EJEEENS0_19unpacking_collectorIXT_EEEDpOT0_:
 2460|     13|unpacking_collector<policy> collect_arguments(Args &&...args) {
 2461|       |    // Following argument order rules for generalized unpacking according to PEP 448
 2462|     13|    static_assert(
 2463|     13|        constexpr_last<is_positional, Args...>() < constexpr_first<is_keyword_or_ds, Args...>(),
 2464|     13|        "Invalid function call: positional args must precede keywords and */** unpacking;");
 2465|     13|    static_assert(constexpr_last<is_s_unpacking, Args...>()
 2466|     13|                      < constexpr_first<is_ds_unpacking, Args...>(),
 2467|     13|                  "Invalid function call: * unpacking must precede ** unpacking");
 2468|     13|    return unpacking_collector<policy>(std::forward<Args>(args)...);
 2469|     13|}
_ZN8pybind116detail19unpacking_collectorILNS_19return_value_policyE1EEC2IJEEEDpOT_:
 2286|     13|        : m_names(reinterpret_steal<tuple>(
 2287|     13|              handle())) // initialize to null to avoid useless allocation of 0-length tuple
 2288|     13|    {
 2289|       |        /*
 2290|       |        Python can sometimes utilize an extra space before the arguments to prepend `self`.
 2291|       |        This is important enough that there is a special flag for it:
 2292|       |        PY_VECTORCALL_ARGUMENTS_OFFSET.
 2293|       |        All we have to do is allocate an extra space at the beginning of this array, and set the
 2294|       |        flag. Note that the extra space is not passed directly in to vectorcall.
 2295|       |        */
 2296|     13|        m_args.reserve(sizeof...(values) + 1);
 2297|     13|        m_args.push_back_null();
 2298|       |
 2299|     13|        if (args_has_keyword_or_ds<Ts...>()) {
  ------------------
  |  Branch (2299:13): [Folded, False: 13]
  ------------------
 2300|      0|            list names_list;
 2301|       |
 2302|       |            // collect_arguments guarantees this can't be constructed with kwargs before the last
 2303|       |            // positional so we don't need to worry about Ts... being in anything but normal python
 2304|       |            // order.
 2305|      0|            using expander = int[];
 2306|      0|            (void) expander{0, (process(names_list, std::forward<Ts>(values)), 0)...};
 2307|       |
 2308|      0|            m_names = reinterpret_steal<tuple>(PyList_AsTuple(names_list.ptr()));
 2309|     13|        } else {
 2310|     13|            auto not_used
 2311|     13|                = reinterpret_steal<list>(handle()); // initialize as null (to avoid an allocation)
 2312|       |
 2313|     13|            using expander = int[];
 2314|     13|            (void) expander{0, (process(not_used, std::forward<Ts>(values)), 0)...};
 2315|     13|        }
 2316|     13|    }

_ZN8pybind116detail16ref_small_vectorILm6EEC2Ev:
  388|  2.36k|    ref_small_vector() = default;
_ZN8pybind116detail12small_vectorIP7_objectLm6EEC2Ev:
  151|  2.36k|    small_vector() = default;
_ZN8pybind116detail22inline_array_or_vectorIP7_objectLm6ES3_EC2Ev:
   88|  2.36k|    inline_array_or_vector() : iarray() {}
_ZN8pybind116detail22inline_array_or_vectorIP7_objectLm6ES3_E12inline_arrayC2Ev:
   58|  2.36k|        inline_array() = default;
_ZN8pybind116detail16ref_small_vectorILm6EE7reserveEm:
  427|  2.36k|    void reserve(std::size_t sz) { m_ptrs.reserve(sz); }
_ZN8pybind116detail12small_vectorIP7_objectLm6EE7reserveEm:
  208|  2.36k|    void reserve(std::size_t sz) {
  209|  2.36k|        if (is_inline()) {
  ------------------
  |  Branch (209:13): [True: 2.36k, False: 0]
  ------------------
  210|  2.36k|            if (sz > InlineSize) {
  ------------------
  |  Branch (210:17): [True: 0, False: 2.36k]
  ------------------
  211|      0|                move_to_heap_vector_with_reserved_size(sz);
  212|      0|            }
  213|  2.36k|        } else {
  214|      0|            reserve_slow_path(sz);
  215|      0|        }
  216|  2.36k|    }
_ZNK8pybind116detail12small_vectorIP7_objectLm6EE9is_inlineEv:
  238|  23.5k|    bool is_inline() const { return m_repr.is_inline(); }
_ZNK8pybind116detail22inline_array_or_vectorIP7_objectLm6ES3_E9is_inlineEv:
  132|  25.9k|    bool is_inline() const {
  133|       |        // It is undefined behavior to access the inactive member of a
  134|       |        // union directly. However, it is well-defined to reinterpret_cast any
  135|       |        // pointer into a pointer to char and examine it as an array
  136|       |        // of bytes. See
  137|       |        // https://dev-discuss.pytorch.org/t/unionizing-for-profit-how-to-exploit-the-power-of-unions-in-c/444#the-memcpy-loophole-4
  138|  25.9k|        bool result = false;
  139|  25.9k|        static_assert(offsetof(inline_array, is_inline) == 0,
  140|  25.9k|                      "untagged union implementation relies on this");
  141|  25.9k|        static_assert(offsetof(heap_vector, is_inline) == 0,
  142|  25.9k|                      "untagged union implementation relies on this");
  143|  25.9k|        std::memcpy(&result, reinterpret_cast<const char *>(this), sizeof(bool));
  144|  25.9k|        return result;
  145|  25.9k|    }
_ZN8pybind116detail16ref_small_vectorILm6EE14push_back_nullEv:
  425|  2.36k|    void push_back_null() { m_ptrs.push_back(nullptr); }
_ZN8pybind116detail12small_vectorIP7_objectLm6EE9push_backEOS3_:
  191|  2.36k|    void push_back(T &&x) { emplace_back(std::move(x)); }
_ZN8pybind116detail12small_vectorIP7_objectLm6EE12emplace_backIJS3_EEEvDpOT_:
  194|  2.36k|    void emplace_back(Args &&...x) {
  195|  2.36k|        if (is_inline()) {
  ------------------
  |  Branch (195:13): [True: 2.36k, False: 0]
  ------------------
  196|  2.36k|            auto &ha = m_repr.iarray;
  197|  2.36k|            if (ha.size == InlineSize) {
  ------------------
  |  Branch (197:17): [True: 0, False: 2.36k]
  ------------------
  198|      0|                move_to_heap_vector_with_reserved_size(InlineSize + 1);
  199|      0|                m_repr.hvector.vec.emplace_back(std::forward<Args>(x)...);
  200|  2.36k|            } else {
  201|  2.36k|                ha.arr[ha.size++] = T(std::forward<Args>(x)...);
  202|  2.36k|            }
  203|  2.36k|        } else {
  204|      0|            m_repr.hvector.vec.emplace_back(std::forward<Args>(x)...);
  205|      0|        }
  206|  2.36k|    }
_ZNK8pybind116detail16ref_small_vectorILm6EE4sizeEv:
  429|  2.35k|    std::size_t size() const { return m_ptrs.size(); }
_ZNK8pybind116detail12small_vectorIP7_objectLm6EE4sizeEv:
  159|  9.41k|    std::size_t size() const {
  160|  9.41k|        if (is_inline()) {
  ------------------
  |  Branch (160:13): [True: 9.41k, False: 0]
  ------------------
  161|  9.41k|            return m_repr.iarray.size;
  162|  9.41k|        }
  163|      0|        return m_repr.hvector.vec.size();
  164|  9.41k|    }
_ZN8pybind116detail16ref_small_vectorILm6EE15push_back_stealEP7_object:
  416|  2.34k|    void push_back_steal(PyObject *p) { m_ptrs.push_back(p); }
_ZN8pybind116detail12small_vectorIP7_objectLm6EE9push_backERKS3_:
  189|  2.34k|    void push_back(const T &x) { emplace_back(x); }
_ZN8pybind116detail12small_vectorIP7_objectLm6EE12emplace_backIJRKS3_EEEvDpOT_:
  194|  2.34k|    void emplace_back(Args &&...x) {
  195|  2.34k|        if (is_inline()) {
  ------------------
  |  Branch (195:13): [True: 2.34k, False: 0]
  ------------------
  196|  2.34k|            auto &ha = m_repr.iarray;
  197|  2.34k|            if (ha.size == InlineSize) {
  ------------------
  |  Branch (197:17): [True: 0, False: 2.34k]
  ------------------
  198|      0|                move_to_heap_vector_with_reserved_size(InlineSize + 1);
  199|      0|                m_repr.hvector.vec.emplace_back(std::forward<Args>(x)...);
  200|  2.34k|            } else {
  201|  2.34k|                ha.arr[ha.size++] = T(std::forward<Args>(x)...);
  202|  2.34k|            }
  203|  2.34k|        } else {
  204|      0|            m_repr.hvector.vec.emplace_back(std::forward<Args>(x)...);
  205|      0|        }
  206|  2.34k|    }
_ZN8pybind116detail16ref_small_vectorILm6EED2Ev:
  390|  2.36k|    ~ref_small_vector() {
  391|  7.06k|        for (std::size_t i = 0; i < m_ptrs.size(); ++i) {
  ------------------
  |  Branch (391:33): [True: 4.70k, False: 2.36k]
  ------------------
  392|       |            Py_XDECREF(m_ptrs[i]);
  393|  4.70k|        }
  394|  2.36k|    }
_ZN8pybind116detail12small_vectorIP7_objectLm6EEixEm:
  173|  4.70k|    T &operator[](std::size_t idx) {
  174|  4.70k|        assert(idx < size());
  175|  4.70k|        if (is_inline()) {
  ------------------
  |  Branch (175:13): [True: 4.70k, False: 0]
  ------------------
  176|  4.70k|            return m_repr.iarray.arr[idx];
  177|  4.70k|        }
  178|      0|        return m_repr.hvector.vec[idx];
  179|  4.70k|    }
_ZN8pybind116detail22inline_array_or_vectorIP7_objectLm6ES3_ED2Ev:
   90|  2.36k|    ~inline_array_or_vector() {
   91|  2.36k|        if (is_inline()) {
  ------------------
  |  Branch (91:13): [True: 2.36k, False: 0]
  ------------------
   92|  2.36k|            iarray.~inline_array();
   93|  2.36k|        } else {
   94|      0|            hvector.~heap_vector();
   95|      0|        }
   96|  2.36k|    }
_ZNK8pybind116detail16ref_small_vectorILm6EE4dataEv:
  433|  2.35k|    PyObject *const *data() const { return m_ptrs.data(); }
_ZNK8pybind116detail12small_vectorIP7_objectLm6EE4dataEv:
  166|  2.35k|    T const *data() const {
  167|  2.35k|        if (is_inline()) {
  ------------------
  |  Branch (167:13): [True: 2.35k, False: 0]
  ------------------
  168|  2.35k|            return m_repr.iarray.arr.data();
  169|  2.35k|        }
  170|      0|        return m_repr.hvector.vec.data();
  171|  2.35k|    }

_ZN8pybind116detail25make_static_property_typeEv:
  139|      1|PYBIND11_INLINE PyTypeObject *make_static_property_type() {
  140|      1|    constexpr auto *name = "pybind11_static_property";
  141|      1|    auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
  ------------------
  |  |  450|      1|#define PYBIND11_FROM_STRING PyUnicode_FromString
  ------------------
  142|       |
  143|       |    /* Danger zone: from now (and until PyType_Ready), make sure to
  144|       |       issue no Python C API calls which could potentially invoke the
  145|       |       garbage collector (the GC will call type_traverse(), which will in
  146|       |       turn find the newly constructed type in an invalid state) */
  147|      1|    auto *heap_type = reinterpret_cast<PyHeapTypeObject *>(PyType_Type.tp_alloc(&PyType_Type, 0));
  148|      1|    if (!heap_type) {
  ------------------
  |  Branch (148:9): [True: 0, False: 1]
  ------------------
  149|      0|        pybind11_fail("make_static_property_type(): error allocating type!");
  150|      0|    }
  151|       |
  152|      1|    heap_type->ht_name = name_obj.inc_ref().ptr();
  153|      1|#        ifdef PYBIND11_BUILTIN_QUALNAME
  154|      1|    heap_type->ht_qualname = name_obj.inc_ref().ptr();
  155|      1|#        endif
  156|       |
  157|      1|    auto *type = &heap_type->ht_type;
  158|      1|    type->tp_name = name;
  159|      1|    type->tp_base = type_incref(&PyProperty_Type);
  160|      1|    type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
  161|      1|    type->tp_descr_get = pybind11_static_get;
  162|      1|    type->tp_descr_set = pybind11_static_set;
  163|       |
  164|       |#        if PY_VERSION_HEX >= 0x030C0000
  165|       |    // Since Python-3.12 property-derived types are required to
  166|       |    // have dynamic attributes (to set `__doc__`)
  167|       |    enable_dynamic_attributes(heap_type);
  168|       |#        endif
  169|       |
  170|      1|    if (PyType_Ready(type) < 0) {
  ------------------
  |  Branch (170:9): [True: 0, False: 1]
  ------------------
  171|      0|        pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
  172|      0|    }
  173|       |
  174|      1|    setattr(reinterpret_cast<PyObject *>(type), "__module__", str(PYBIND11_DUMMY_MODULE_NAME));
  ------------------
  |  |  227|      1|#define PYBIND11_DUMMY_MODULE_NAME "pybind11_builtins"
  ------------------
  175|      1|    PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
  176|       |
  177|      1|    return type;
  178|      1|}
_ZN8pybind116detail11type_increfEP11_typeobject:
   38|      3|PYBIND11_INLINE PyTypeObject *type_incref(PyTypeObject *type) {
   39|       |    Py_INCREF(reinterpret_cast<PyObject *>(type));
   40|      3|    return type;
   41|      3|}
_ZN8pybind116detail22make_default_metaclassEv:
  339|      1|PYBIND11_INLINE PyTypeObject *make_default_metaclass() {
  340|      1|    constexpr auto *name = "pybind11_type";
  341|      1|    auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
  ------------------
  |  |  450|      1|#define PYBIND11_FROM_STRING PyUnicode_FromString
  ------------------
  342|       |
  343|       |    /* Danger zone: from now (and until PyType_Ready), make sure to
  344|       |       issue no Python C API calls which could potentially invoke the
  345|       |       garbage collector (the GC will call type_traverse(), which will in
  346|       |       turn find the newly constructed type in an invalid state) */
  347|      1|    auto *heap_type = reinterpret_cast<PyHeapTypeObject *>(PyType_Type.tp_alloc(&PyType_Type, 0));
  348|      1|    if (!heap_type) {
  ------------------
  |  Branch (348:9): [True: 0, False: 1]
  ------------------
  349|      0|        pybind11_fail("make_default_metaclass(): error allocating metaclass!");
  350|      0|    }
  351|       |
  352|      1|    heap_type->ht_name = name_obj.inc_ref().ptr();
  353|      1|#    ifdef PYBIND11_BUILTIN_QUALNAME
  354|      1|    heap_type->ht_qualname = name_obj.inc_ref().ptr();
  355|      1|#    endif
  356|       |
  357|      1|    auto *type = &heap_type->ht_type;
  358|      1|    type->tp_name = name;
  359|      1|    type->tp_base = type_incref(&PyType_Type);
  360|      1|    type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
  361|       |
  362|      1|    type->tp_call = pybind11_meta_call;
  363|       |
  364|      1|    type->tp_setattro = pybind11_meta_setattro;
  365|      1|    type->tp_getattro = pybind11_meta_getattro;
  366|       |
  367|      1|    type->tp_dealloc = pybind11_meta_dealloc;
  368|       |
  369|      1|    if (PyType_Ready(type) < 0) {
  ------------------
  |  Branch (369:9): [True: 0, False: 1]
  ------------------
  370|      0|        pybind11_fail("make_default_metaclass(): failure in PyType_Ready()!");
  371|      0|    }
  372|       |
  373|      1|    setattr(reinterpret_cast<PyObject *>(type), "__module__", str(PYBIND11_DUMMY_MODULE_NAME));
  ------------------
  |  |  227|      1|#define PYBIND11_DUMMY_MODULE_NAME "pybind11_builtins"
  ------------------
  374|      1|    PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
  375|       |
  376|      1|    return type;
  377|      1|}
pybind11_meta_setattro:
  205|      1|pybind11_meta_setattro(PyObject *obj, PyObject *name, PyObject *value) {
  206|       |    // Use `type_lookup()` instead of `PyObject_GetAttr()` in order to get the raw
  207|       |    // descriptor (`property`) instead of calling `tp_descr_get` (`property.__get__()`).
  208|      1|    auto descr = type_lookup((PyTypeObject *) obj, name);
  209|       |
  210|       |    // The following assignment combinations are possible:
  211|       |    //   1. `Type.static_prop = value`             --> descr_set: `Type.static_prop.__set__(value)`
  212|       |    //   2. `Type.static_prop = other_static_prop` --> setattro:  replace existing `static_prop`
  213|       |    //   3. `Type.regular_attribute = value`       --> setattro:  regular attribute assignment
  214|      1|    auto *const static_prop = (PyObject *) get_internals().static_property_type;
  215|      1|    const auto call_descr_set = descr && (value != nullptr)
  ------------------
  |  Branch (215:33): [True: 0, False: 1]
  |  Branch (215:42): [True: 0, False: 0]
  ------------------
  216|      0|                                && (PyObject_IsInstance(descr.ptr(), static_prop) != 0)
  ------------------
  |  Branch (216:36): [True: 0, False: 0]
  ------------------
  217|      0|                                && (PyObject_IsInstance(value, static_prop) == 0);
  ------------------
  |  Branch (217:36): [True: 0, False: 0]
  ------------------
  218|      1|    if (call_descr_set) {
  ------------------
  |  Branch (218:9): [True: 0, False: 1]
  ------------------
  219|       |        // Call `static_property.__set__()` instead of replacing the `static_property`.
  220|      0|#if defined(PYBIND11_HAS_DIRECT_STRUCT_ACCESS)
  221|      0|        return Py_TYPE(descr.ptr())->tp_descr_set(descr.ptr(), obj, value);
  222|       |#else
  223|       |        if (PyObject *result = PyObject_CallMethod(descr.ptr(), "__set__", "OO", obj, value)) {
  224|       |            Py_DECREF(result);
  225|       |            return 0;
  226|       |        } else {
  227|       |            return -1;
  228|       |        }
  229|       |#endif
  230|      1|    } else {
  231|       |        // Replace existing attribute.
  232|      1|        return type_type_setattro()(obj, name, value);
  233|      1|    }
  234|      1|}
_ZN8pybind116detail18type_type_setattroEv:
   61|      1|        PYBIND11_INLINE slot_type fn() {                                                          \
   62|      1|            static const auto cached                                                              \
   63|      1|                = reinterpret_cast<slot_type>(PyType_GetSlot(&(type), slot_id));                  \
   64|      1|            return cached;                                                                        \
   65|      1|        }
_ZN8pybind116detail21make_object_base_typeEP11_typeobject:
  881|      1|PYBIND11_INLINE PyObject *make_object_base_type(PyTypeObject *metaclass) {
  882|      1|    constexpr auto *name = "pybind11_object";
  883|      1|    auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
  ------------------
  |  |  450|      1|#define PYBIND11_FROM_STRING PyUnicode_FromString
  ------------------
  884|       |
  885|       |    /* Danger zone: from now (and until PyType_Ready), make sure to
  886|       |       issue no Python C API calls which could potentially invoke the
  887|       |       garbage collector (the GC will call type_traverse(), which will in
  888|       |       turn find the newly constructed type in an invalid state) */
  889|      1|    auto *heap_type = reinterpret_cast<PyHeapTypeObject *>(metaclass->tp_alloc(metaclass, 0));
  890|      1|    if (!heap_type) {
  ------------------
  |  Branch (890:9): [True: 0, False: 1]
  ------------------
  891|      0|        pybind11_fail("make_object_base_type(): error allocating type!");
  892|      0|    }
  893|       |
  894|      1|    heap_type->ht_name = name_obj.inc_ref().ptr();
  895|      1|#    ifdef PYBIND11_BUILTIN_QUALNAME
  896|      1|    heap_type->ht_qualname = name_obj.inc_ref().ptr();
  897|      1|#    endif
  898|       |
  899|      1|    auto *type = &heap_type->ht_type;
  900|      1|    type->tp_name = name;
  901|      1|    type->tp_base = type_incref(&PyBaseObject_Type);
  902|      1|    type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
  903|      1|    type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
  904|       |
  905|      1|    type->tp_new = pybind11_object_new;
  906|      1|    type->tp_init = pybind11_object_init;
  907|      1|    type->tp_dealloc = pybind11_object_dealloc;
  908|       |
  909|       |    /* Support weak references (needed for the keep_alive feature) */
  910|      1|    type->tp_weaklistoffset = offsetof(instance, weakrefs);
  911|       |
  912|      1|    if (PyType_Ready(type) < 0) {
  ------------------
  |  Branch (912:9): [True: 0, False: 1]
  ------------------
  913|      0|        pybind11_fail("PyType_Ready failed in make_object_base_type(): " + error_string());
  914|      0|    }
  915|       |
  916|      1|    setattr(reinterpret_cast<PyObject *>(type), "__module__", str(PYBIND11_DUMMY_MODULE_NAME));
  ------------------
  |  |  227|      1|#define PYBIND11_DUMMY_MODULE_NAME "pybind11_builtins"
  ------------------
  917|      1|    PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
  918|       |
  919|       |    assert(!PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
  920|      1|    return reinterpret_cast<PyObject *>(heap_type);
  921|      1|}

_ZN8pybind1112ssize_t_castImEElRKT_:
  699|  7.14k|inline ssize_t ssize_t_cast(const IntType &val) {
  700|  7.14k|    static_assert(sizeof(IntType) <= sizeof(ssize_t), "Implicit narrowing is not permitted.");
  701|  7.14k|    return static_cast<ssize_t>(val);
  702|  7.14k|}
_ZN8pybind1111error_scopeC2Ev:
 1414|  6.85k|    error_scope() { PyErr_Fetch(&type, &value, &trace); }
_ZN8pybind1111error_scopeD2Ev:
 1417|  6.85k|    ~error_scope() { PyErr_Restore(type, value, trace); }

_ZN8pybind116detail13get_internalsEv:
  180|  6.85k|PYBIND11_NOINLINE_ATTR PYBIND11_INLINE internals &get_internals() {
  181|  6.85k|    auto &ppmgr = get_internals_pp_manager();
  182|  6.85k|    auto *pp = ppmgr.get_pp();
  183|  6.85k|    if (!pp) {
  ------------------
  |  Branch (183:9): [True: 0, False: 6.85k]
  ------------------
  184|      0|        pybind11_fail("get_internals: get_pp() returned nullptr");
  185|      0|    }
  186|  6.85k|    auto &internals_ptr = *pp;
  187|  6.85k|    if (!internals_ptr) {
  ------------------
  |  Branch (187:9): [True: 1, False: 6.85k]
  ------------------
  188|       |        // Slow path, something needs fetched from the state dict or created
  189|      1|        gil_scoped_acquire_simple gil;
  190|      1|        error_scope err_scope;
  191|       |
  192|      1|        ppmgr.create_pp_content_once(&internals_ptr);
  193|       |
  194|      1|        if (!internals_ptr) {
  ------------------
  |  Branch (194:13): [True: 0, False: 1]
  ------------------
  195|      0|            pybind11_fail("get_internals: create_pp_content_once() produced nullptr");
  196|      0|        }
  197|      1|        if (!internals_ptr->instance_base) {
  ------------------
  |  Branch (197:13): [True: 1, False: 0]
  ------------------
  198|       |            // This calls get_internals, so cannot be called from within the internals constructor
  199|       |            // called above because internals_ptr must be set before get_internals is called again
  200|      1|            internals_ptr->instance_base = make_object_base_type(internals_ptr->default_metaclass);
  201|      1|        }
  202|      1|    }
  203|  6.85k|    return *internals_ptr;
  204|  6.85k|}
_ZN8pybind116detail24get_internals_pp_managerEv:
  170|  6.85k|PYBIND11_INLINE internals_pp_manager<internals> &get_internals_pp_manager() {
  171|       |#if defined(__GLIBCXX__)
  172|       |#    define ON_FETCH_FN nullptr
  173|       |#else
  174|  6.85k|#    define ON_FETCH_FN &check_internals_local_exception_translator
  175|  6.85k|#endif
  176|  6.85k|    return internals_pp_manager<internals>::get_instance(PYBIND11_INTERNALS_ID, ON_FETCH_FN);
  ------------------
  |  |  599|  6.85k|    "__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION)                        \
  |  |  600|  6.85k|        PYBIND11_COMPILER_TYPE_LEADING_UNDERSCORE                                                 \
  |  |  601|  6.85k|            PYBIND11_PLATFORM_ABI_ID PYBIND11_INTERNALS_SABI_TAG "__"
  ------------------
                  return internals_pp_manager<internals>::get_instance(PYBIND11_INTERNALS_ID, ON_FETCH_FN);
  ------------------
  |  |  174|  6.85k|#    define ON_FETCH_FN &check_internals_local_exception_translator
  ------------------
  177|  6.85k|#undef ON_FETCH_FN
  178|  6.85k|}
_ZN8pybind116detail21get_python_state_dictEv:
   24|      2|PYBIND11_INLINE object get_python_state_dict() {
   25|      2|    object state_dict;
   26|       |#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
   27|       |    state_dict = reinterpret_borrow<object>(PyEval_GetBuiltins());
   28|       |#else
   29|      2|    auto *istate = get_current_interpreter_state();
   30|      2|    if (istate) {
  ------------------
  |  Branch (30:9): [True: 2, False: 0]
  ------------------
   31|      2|        state_dict = reinterpret_borrow<object>(PyInterpreterState_GetDict(istate));
   32|      2|    }
   33|      2|#endif
   34|      2|    if (!state_dict) {
  ------------------
  |  Branch (34:9): [True: 0, False: 2]
  ------------------
   35|      0|        raise_from(PyExc_SystemError, "pybind11::detail::get_python_state_dict() FAILED");
   36|      0|        throw error_already_set();
   37|      0|    }
   38|      2|    return state_dict;
   39|      2|}
_ZN8pybind116detail30get_local_internals_pp_managerEv:
  238|      3|PYBIND11_INLINE internals_pp_manager<local_internals> &get_local_internals_pp_manager() {
  239|       |    // Use the address of a static variable as part of the key, so that the value is uniquely tied
  240|       |    // to where the module is loaded in memory
  241|      3|    return internals_pp_manager<local_internals>::get_instance(get_local_internals_key().c_str(),
  242|      3|                                                               nullptr);
  243|      3|}
_ZN8pybind116detail23get_local_internals_keyEv:
  211|      3|PYBIND11_INLINE const std::string &get_local_internals_key() {
  212|      3|    static const std::string key
  213|      3|        = PYBIND11_MODULE_LOCAL_ID + std::to_string(reinterpret_cast<uintptr_t>(&key));
  ------------------
  |  |  604|      6|    "__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION)                     \
  |  |  605|      6|        PYBIND11_COMPILER_TYPE_LEADING_UNDERSCORE                                                 \
  |  |  606|      6|            PYBIND11_PLATFORM_ABI_ID PYBIND11_INTERNALS_SABI_TAG "__"
  ------------------
  214|      3|    return key;
  215|      3|}
_ZN8pybind116detail29has_seen_non_main_interpreterEv:
   55|      3|PYBIND11_INLINE std::atomic_bool &has_seen_non_main_interpreter() {
   56|      3|    static std::atomic_bool multi(false);
   57|      3|    return multi;
   58|      3|}

_ZN8pybind116detail20internals_pp_managerINS0_9internalsEE12get_instanceEPKcPFvPS2_E:
  752|  6.85k|    static internals_pp_manager &get_instance(char const *id, on_fetch_function *on_fetch) {
  753|  6.85k|        static internals_pp_manager instance(id, on_fetch);
  754|  6.85k|        return instance;
  755|  6.85k|    }
_ZN8pybind116detail20internals_pp_managerINS0_9internalsEEC2EPKcPFvPS2_E:
  862|      1|        : holder_id_(id), on_fetch_(on_fetch) {}
_ZN8pybind116detail20internals_pp_managerINS0_9internalsEE6get_ppEv:
  759|  6.85k|    std::unique_ptr<InternalsType> *get_pp() {
  760|       |#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
  761|       |        if (has_seen_non_main_interpreter()) {
  762|       |            // Whenever the interpreter changes on the current thread we need to invalidate the
  763|       |            // internals_pp so that it can be pulled from the interpreter's state dict.  That is
  764|       |            // slow, so we use the current PyThreadState to check if it is necessary.
  765|       |            auto *tstate = get_thread_state_unchecked();
  766|       |            if (!tstate || get_interpreter(tstate) != last_istate_tls()) {
  767|       |                gil_scoped_acquire_simple gil;
  768|       |                if (!tstate) {
  769|       |                    tstate = get_thread_state_unchecked();
  770|       |                }
  771|       |                // Update the cache only on success; a stale interp with a null pp would make
  772|       |                // later calls return nullptr.
  773|       |                auto *pp = get_or_create_pp_in_state_dict();
  774|       |                last_istate_tls() = get_interpreter(tstate);
  775|       |                internals_p_tls() = pp;
  776|       |            }
  777|       |            return internals_p_tls();
  778|       |        }
  779|       |#endif
  780|  6.85k|        if (!internals_singleton_pp_) {
  ------------------
  |  Branch (780:13): [True: 1, False: 6.85k]
  ------------------
  781|      1|            gil_scoped_acquire_simple gil;
  782|      1|            internals_singleton_pp_ = get_or_create_pp_in_state_dict();
  783|      1|        }
  784|  6.85k|        return internals_singleton_pp_;
  785|  6.85k|    }
_ZN8pybind116detail20internals_pp_managerINS0_9internalsEE30get_or_create_pp_in_state_dictEv:
  864|      1|    std::unique_ptr<InternalsType> *get_or_create_pp_in_state_dict() {
  865|       |        // The `unique_ptr<InternalsType>` is intentionally leaked on interpreter shutdown.
  866|       |        // Once an instance is created, it will never be deleted until the process exits (compare
  867|       |        // to interpreter shutdown in multiple-interpreter scenarios).
  868|       |        // We cannot guarantee the destruction order of capsules in the interpreter state dict on
  869|       |        // interpreter shutdown, so deleting internals too early could cause undefined behavior
  870|       |        // when other pybind11 objects access `get_internals()` during finalization (which would
  871|       |        // recreate empty internals). See also create_pp_content_once() above.
  872|       |        // See https://github.com/pybind/pybind11/pull/5958#discussion_r2717645230.
  873|      1|        auto result = atomic_get_or_create_in_state_dict<std::unique_ptr<InternalsType>>(
  874|      1|            holder_id_, /*dtor=*/nullptr /* leak the capsule content */);
  875|      1|        auto *pp = result.first;
  876|      1|        bool created = result.second;
  877|       |        // Only call on_fetch_ when fetching existing internals, not when creating new ones.
  878|      1|        if (!created && on_fetch_ && pp) {
  ------------------
  |  Branch (878:13): [True: 0, False: 1]
  |  Branch (878:25): [True: 0, False: 0]
  |  Branch (878:38): [True: 0, False: 0]
  ------------------
  879|      0|            on_fetch_(pp->get());
  880|      0|        }
  881|      1|        return pp;
  882|      1|    }
_ZN8pybind116detail34atomic_get_or_create_in_state_dictINSt3__110unique_ptrINS0_9internalsENS2_14default_deleteIS4_EEEEEENS2_4pairIPT_bEEPKcPFvP7_objectE:
  668|      1|                                                              = PYBIND11_DTOR_USE_DELETE) {
  669|      1|    error_scope err_scope; // preserve any existing Python error states
  670|       |
  671|      1|    auto state_dict = reinterpret_borrow<dict>(get_python_state_dict());
  672|      1|    PyObject *capsule_obj = nullptr;
  673|      1|    bool created = false;
  674|       |
  675|       |    // Try to get existing storage (fast path).
  676|      1|    capsule_obj = dict_getitemstring(state_dict.ptr(), key);
  677|      1|    if (capsule_obj == nullptr) {
  ------------------
  |  Branch (677:9): [True: 1, False: 0]
  ------------------
  678|      1|        if (PyErr_Occurred()) {
  ------------------
  |  Branch (678:13): [True: 0, False: 1]
  ------------------
  679|      0|            throw error_already_set();
  680|      0|        }
  681|       |        // Storage doesn't exist yet, create a new one.
  682|       |        // Use unique_ptr for exception safety: if capsule creation throws, the storage is
  683|       |        // automatically deleted.
  684|      1|        auto storage_ptr = std::unique_ptr<Payload>(new Payload{});
  685|      1|        auto new_capsule
  686|      1|            = capsule(storage_ptr.get(),
  687|       |                      // The destructor will be called when the capsule is GC'ed.
  688|       |                      //  If the insert below fails (entry already in the dict), then this
  689|       |                      //  destructor will be called on the newly created capsule at the end of this
  690|       |                      //  function, and we want to just release this memory.
  691|      1|                      /*destructor=*/[](void *v) { delete static_cast<Payload *>(v); });
  692|       |        // At this point, the capsule object is created successfully.
  693|       |        // Release the unique_ptr and let the capsule object own the storage to avoid double-free.
  694|      1|        (void) storage_ptr.release();
  695|       |
  696|       |        // Use `PyDict_SetDefault` for atomic test-and-set:
  697|       |        //   - If key doesn't exist, inserts our capsule and returns it.
  698|       |        //   - If key exists (another thread inserted first), returns the existing value.
  699|       |        // This is thread-safe because `PyDict_SetDefault` will hold a lock on the dict.
  700|       |        //
  701|       |        // NOTE: Here we use `PyDict_SetDefault` instead of `PyDict_SetDefaultRef` because the
  702|       |        //       capsule is kept alive until interpreter shutdown, so we do not need to handle
  703|       |        //       incref and decref here.
  704|      1|        capsule_obj = dict_setdefaultstring(state_dict.ptr(), key, new_capsule.ptr());
  705|      1|        if (capsule_obj == nullptr) {
  ------------------
  |  Branch (705:13): [True: 0, False: 1]
  ------------------
  706|      0|            throw error_already_set();
  707|      0|        }
  708|      1|        created = (capsule_obj == new_capsule.ptr());
  709|       |        // - If key already existed, our `new_capsule` is not inserted, it will be destructed when
  710|       |        //   going out of scope here, and will call the destructor set above.
  711|       |        // - Otherwise, our `new_capsule` is now in the dict, and it owns the storage and the state
  712|       |        //   dict will incref it.  We need to set the caller's destructor on it, which will be
  713|       |        //   called when the interpreter shuts down.
  714|      1|        if (created && dtor != PYBIND11_DTOR_USE_DELETE) {
  ------------------
  |  |  643|      1|#define PYBIND11_DTOR_USE_DELETE (reinterpret_cast<void (*)(PyObject *)>(1))
  ------------------
  |  Branch (714:13): [True: 1, False: 0]
  |  Branch (714:24): [True: 1, False: 0]
  ------------------
  715|      1|            if (PyCapsule_SetDestructor(capsule_obj, dtor) < 0) {
  ------------------
  |  Branch (715:17): [True: 0, False: 1]
  ------------------
  716|      0|                throw error_already_set();
  717|      0|            }
  718|      1|        }
  719|      1|    }
  720|       |
  721|       |    // Get the storage pointer from the capsule.
  722|      1|    void *raw_ptr = PyCapsule_GetPointer(capsule_obj, /*name=*/nullptr);
  723|      1|    if (!raw_ptr) {
  ------------------
  |  Branch (723:9): [True: 0, False: 1]
  ------------------
  724|      0|        raise_from(PyExc_SystemError,
  725|      0|                   "pybind11::detail::atomic_get_or_create_in_state_dict() FAILED");
  726|      0|        throw error_already_set();
  727|      0|    }
  728|      1|    return std::pair<Payload *, bool>(static_cast<Payload *>(raw_ptr), created);
  729|      1|}
_ZN8pybind116detail29get_current_interpreter_stateEv:
  262|      3|inline PyInterpreterState *get_current_interpreter_state() {
  263|       |#if defined(Py_LIMITED_API)
  264|       |    return PyInterpreterState_Get();
  265|       |#else
  266|      3|    auto *tstate = get_thread_state_unchecked();
  267|      3|    return tstate ? get_interpreter(tstate) : nullptr;
  ------------------
  |  Branch (267:12): [True: 3, False: 0]
  ------------------
  268|      3|#endif
  269|      3|}
_ZN8pybind116detail15get_interpreterEP3_ts:
  251|      3|inline PyInterpreterState *get_interpreter(PyThreadState *tstate) {
  252|       |#if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x08000000
  253|       |    // Missing in some PyPy 7.x releases (e.g. 7.3.19).
  254|       |    return tstate->interp;
  255|       |#else
  256|      3|    return PyThreadState_GetInterpreter(tstate);
  257|      3|#endif
  258|      3|}
_ZN8pybind116detail9internalsD2Ev:
  493|      1|    ~internals() = default;
_ZN8pybind1123thread_specific_storageI3_tsED2Ev:
  179|      1|    ~thread_specific_storage() {
  180|       |        // This destructor is often called *after* Py_Finalize(). That *SHOULD BE* fine on most
  181|       |        // platforms. The following details what happens when PyThread_tss_free is called in
  182|       |        // CPython. PYBIND11_TLS_FREE is PyThread_tss_free on python 3.7+. On older python, it does
  183|       |        // nothing. PyThread_tss_free calls PyThread_tss_delete and PyMem_RawFree.
  184|       |        // PyThread_tss_delete just calls TlsFree (on Windows) or pthread_key_delete (on *NIX).
  185|       |        // Neither of those have anything to do with CPython internals. PyMem_RawFree *requires*
  186|       |        // that the `key` be allocated with the CPython allocator (as it is by
  187|       |        // PyThread_tss_create).
  188|       |        // However, in GraalPy (as of v25.0 or older), TSS is implemented by Java and this call
  189|       |        // requires a living Python interpreter.
  190|       |#ifdef GRAALVM_PYTHON
  191|       |#    if PY_VERSION_HEX >= 0x030D0000
  192|       |        if (Py_IsInitialized() == 0 || Py_IsFinalizing() != 0) {
  193|       |#    else
  194|       |        if (Py_IsInitialized() == 0 || _Py_IsFinalizing() != 0) {
  195|       |#    endif
  196|       |            return;
  197|       |        }
  198|       |#endif
  199|      1|        PYBIND11_TLS_FREE(key_);
  ------------------
  |  |  163|      1|#    define PYBIND11_TLS_FREE(key) PyThread_tss_delete(&(key))
  ------------------
  200|      1|    }
_ZN8pybind116detail20internals_pp_managerINS0_9internalsEE22create_pp_content_onceEPNSt3__110unique_ptrIS2_NS4_14default_deleteIS2_EEEE:
  824|      1|    void create_pp_content_once(std::unique_ptr<InternalsType> *const pp) {
  825|       |        // Assume the GIL is held here. May call back into Python. We cannot hold the lock with our
  826|       |        // mutex here. So there may be multiple threads creating the content at the same time. Only
  827|       |        // one will install its content to pp below. Others will be freed when going out of scope.
  828|      1|        auto tmp = std::unique_ptr<InternalsType>(new InternalsType());
  829|       |
  830|      1|        {
  831|       |            // Lock scope must not include Python calls, which may require the GIL and cause
  832|       |            // deadlocks.
  833|      1|            std::lock_guard<spinlock> lock(pp_set_lock_);
  834|       |
  835|      1|            if (*pp) {
  ------------------
  |  Branch (835:17): [True: 0, False: 1]
  ------------------
  836|       |                // Already created in another thread.
  837|      0|                return;
  838|      0|            }
  839|       |
  840|       |            // At this point, pp->get() is nullptr.
  841|       |            // The content is either not yet created, or was previously destroyed via pp->reset().
  842|       |
  843|       |            // Detect re-creation of internals after destruction during interpreter shutdown.
  844|       |            // If pybind11 code (e.g., tp_traverse/tp_clear calling py::cast) runs after internals
  845|       |            // have been destroyed, a new empty internals would be created, causing type lookup
  846|       |            // failures. See also get_or_create_pp_in_state_dict() comments.
  847|      1|            if (pps_have_created_content_.find(pp) != pps_have_created_content_.end()) {
  ------------------
  |  Branch (847:17): [True: 0, False: 1]
  ------------------
  848|      0|                pybind11_fail(
  849|      0|                    "pybind11::detail::internals_pp_manager::create_pp_content_once() "
  850|      0|                    "FAILED: reentrant call detected while fetching pybind11 internals!");
  851|      0|            }
  852|       |
  853|       |            // Each interpreter can only create its internals once.
  854|      1|            pps_have_created_content_.insert(pp);
  855|       |            // Install the created content.
  856|      1|            pp->swap(tmp);
  857|      1|        }
  858|      1|    }
_ZN8pybind116detail9internalsC2Ev:
  468|      1|        : static_property_type(make_static_property_type()),
  469|      1|          default_metaclass(make_default_metaclass()),
  470|       |#if defined(Py_LIMITED_API)
  471|       |          instancemethod_type(make_instancemethod_type()),
  472|       |#endif
  473|      1|          istate(get_current_interpreter_state()) {
  474|      1|        tstate.set(nullptr); // See PR #5870
  475|      1|        registered_exception_translators.push_front(&translate_exception);
  476|       |#ifdef Py_GIL_DISABLED
  477|       |        // Scale proportional to the number of cores. 2x is a heuristic to reduce contention.
  478|       |        // Make sure the number isn't unreasonable by limiting it to 16 bits (65K)
  479|       |        auto num_shards = static_cast<std::uint16_t>(
  480|       |            std::min<std::size_t>(round_up_to_next_pow2(2 * std::thread::hardware_concurrency()),
  481|       |                                  std::numeric_limits<std::uint16_t>::max()));
  482|       |        if (num_shards == 0) {
  483|       |            num_shards = 1;
  484|       |        }
  485|       |        instance_shards.reset(new instance_map_shard[num_shards]);
  486|       |        instance_shards_mask = num_shards - 1;
  487|       |#endif
  488|      1|    }
_ZN8pybind116detail20internals_pp_managerINS0_15local_internalsEE12get_instanceEPKcPFvPS2_E:
  752|      3|    static internals_pp_manager &get_instance(char const *id, on_fetch_function *on_fetch) {
  753|      3|        static internals_pp_manager instance(id, on_fetch);
  754|      3|        return instance;
  755|      3|    }
_ZN8pybind116detail20internals_pp_managerINS0_15local_internalsEEC2EPKcPFvPS2_E:
  862|      1|        : holder_id_(id), on_fetch_(on_fetch) {}
_ZN8pybind116detail20internals_pp_managerINS0_15local_internalsEE6get_ppEv:
  759|      1|    std::unique_ptr<InternalsType> *get_pp() {
  760|       |#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
  761|       |        if (has_seen_non_main_interpreter()) {
  762|       |            // Whenever the interpreter changes on the current thread we need to invalidate the
  763|       |            // internals_pp so that it can be pulled from the interpreter's state dict.  That is
  764|       |            // slow, so we use the current PyThreadState to check if it is necessary.
  765|       |            auto *tstate = get_thread_state_unchecked();
  766|       |            if (!tstate || get_interpreter(tstate) != last_istate_tls()) {
  767|       |                gil_scoped_acquire_simple gil;
  768|       |                if (!tstate) {
  769|       |                    tstate = get_thread_state_unchecked();
  770|       |                }
  771|       |                // Update the cache only on success; a stale interp with a null pp would make
  772|       |                // later calls return nullptr.
  773|       |                auto *pp = get_or_create_pp_in_state_dict();
  774|       |                last_istate_tls() = get_interpreter(tstate);
  775|       |                internals_p_tls() = pp;
  776|       |            }
  777|       |            return internals_p_tls();
  778|       |        }
  779|       |#endif
  780|      1|        if (!internals_singleton_pp_) {
  ------------------
  |  Branch (780:13): [True: 1, False: 0]
  ------------------
  781|      1|            gil_scoped_acquire_simple gil;
  782|      1|            internals_singleton_pp_ = get_or_create_pp_in_state_dict();
  783|      1|        }
  784|      1|        return internals_singleton_pp_;
  785|      1|    }
_ZN8pybind116detail20internals_pp_managerINS0_15local_internalsEE30get_or_create_pp_in_state_dictEv:
  864|      1|    std::unique_ptr<InternalsType> *get_or_create_pp_in_state_dict() {
  865|       |        // The `unique_ptr<InternalsType>` is intentionally leaked on interpreter shutdown.
  866|       |        // Once an instance is created, it will never be deleted until the process exits (compare
  867|       |        // to interpreter shutdown in multiple-interpreter scenarios).
  868|       |        // We cannot guarantee the destruction order of capsules in the interpreter state dict on
  869|       |        // interpreter shutdown, so deleting internals too early could cause undefined behavior
  870|       |        // when other pybind11 objects access `get_internals()` during finalization (which would
  871|       |        // recreate empty internals). See also create_pp_content_once() above.
  872|       |        // See https://github.com/pybind/pybind11/pull/5958#discussion_r2717645230.
  873|      1|        auto result = atomic_get_or_create_in_state_dict<std::unique_ptr<InternalsType>>(
  874|      1|            holder_id_, /*dtor=*/nullptr /* leak the capsule content */);
  875|      1|        auto *pp = result.first;
  876|      1|        bool created = result.second;
  877|       |        // Only call on_fetch_ when fetching existing internals, not when creating new ones.
  878|      1|        if (!created && on_fetch_ && pp) {
  ------------------
  |  Branch (878:13): [True: 0, False: 1]
  |  Branch (878:25): [True: 0, False: 0]
  |  Branch (878:38): [True: 0, False: 0]
  ------------------
  879|      0|            on_fetch_(pp->get());
  880|      0|        }
  881|      1|        return pp;
  882|      1|    }
_ZN8pybind116detail34atomic_get_or_create_in_state_dictINSt3__110unique_ptrINS0_15local_internalsENS2_14default_deleteIS4_EEEEEENS2_4pairIPT_bEEPKcPFvP7_objectE:
  668|      1|                                                              = PYBIND11_DTOR_USE_DELETE) {
  669|      1|    error_scope err_scope; // preserve any existing Python error states
  670|       |
  671|      1|    auto state_dict = reinterpret_borrow<dict>(get_python_state_dict());
  672|      1|    PyObject *capsule_obj = nullptr;
  673|      1|    bool created = false;
  674|       |
  675|       |    // Try to get existing storage (fast path).
  676|      1|    capsule_obj = dict_getitemstring(state_dict.ptr(), key);
  677|      1|    if (capsule_obj == nullptr) {
  ------------------
  |  Branch (677:9): [True: 1, False: 0]
  ------------------
  678|      1|        if (PyErr_Occurred()) {
  ------------------
  |  Branch (678:13): [True: 0, False: 1]
  ------------------
  679|      0|            throw error_already_set();
  680|      0|        }
  681|       |        // Storage doesn't exist yet, create a new one.
  682|       |        // Use unique_ptr for exception safety: if capsule creation throws, the storage is
  683|       |        // automatically deleted.
  684|      1|        auto storage_ptr = std::unique_ptr<Payload>(new Payload{});
  685|      1|        auto new_capsule
  686|      1|            = capsule(storage_ptr.get(),
  687|       |                      // The destructor will be called when the capsule is GC'ed.
  688|       |                      //  If the insert below fails (entry already in the dict), then this
  689|       |                      //  destructor will be called on the newly created capsule at the end of this
  690|       |                      //  function, and we want to just release this memory.
  691|      1|                      /*destructor=*/[](void *v) { delete static_cast<Payload *>(v); });
  692|       |        // At this point, the capsule object is created successfully.
  693|       |        // Release the unique_ptr and let the capsule object own the storage to avoid double-free.
  694|      1|        (void) storage_ptr.release();
  695|       |
  696|       |        // Use `PyDict_SetDefault` for atomic test-and-set:
  697|       |        //   - If key doesn't exist, inserts our capsule and returns it.
  698|       |        //   - If key exists (another thread inserted first), returns the existing value.
  699|       |        // This is thread-safe because `PyDict_SetDefault` will hold a lock on the dict.
  700|       |        //
  701|       |        // NOTE: Here we use `PyDict_SetDefault` instead of `PyDict_SetDefaultRef` because the
  702|       |        //       capsule is kept alive until interpreter shutdown, so we do not need to handle
  703|       |        //       incref and decref here.
  704|      1|        capsule_obj = dict_setdefaultstring(state_dict.ptr(), key, new_capsule.ptr());
  705|      1|        if (capsule_obj == nullptr) {
  ------------------
  |  Branch (705:13): [True: 0, False: 1]
  ------------------
  706|      0|            throw error_already_set();
  707|      0|        }
  708|      1|        created = (capsule_obj == new_capsule.ptr());
  709|       |        // - If key already existed, our `new_capsule` is not inserted, it will be destructed when
  710|       |        //   going out of scope here, and will call the destructor set above.
  711|       |        // - Otherwise, our `new_capsule` is now in the dict, and it owns the storage and the state
  712|       |        //   dict will incref it.  We need to set the caller's destructor on it, which will be
  713|       |        //   called when the interpreter shuts down.
  714|      1|        if (created && dtor != PYBIND11_DTOR_USE_DELETE) {
  ------------------
  |  |  643|      1|#define PYBIND11_DTOR_USE_DELETE (reinterpret_cast<void (*)(PyObject *)>(1))
  ------------------
  |  Branch (714:13): [True: 1, False: 0]
  |  Branch (714:24): [True: 1, False: 0]
  ------------------
  715|      1|            if (PyCapsule_SetDestructor(capsule_obj, dtor) < 0) {
  ------------------
  |  Branch (715:17): [True: 0, False: 1]
  ------------------
  716|      0|                throw error_already_set();
  717|      0|            }
  718|      1|        }
  719|      1|    }
  720|       |
  721|       |    // Get the storage pointer from the capsule.
  722|      1|    void *raw_ptr = PyCapsule_GetPointer(capsule_obj, /*name=*/nullptr);
  723|      1|    if (!raw_ptr) {
  ------------------
  |  Branch (723:9): [True: 0, False: 1]
  ------------------
  724|      0|        raise_from(PyExc_SystemError,
  725|      0|                   "pybind11::detail::atomic_get_or_create_in_state_dict() FAILED");
  726|      0|        throw error_already_set();
  727|      0|    }
  728|      1|    return std::pair<Payload *, bool>(static_cast<Payload *>(raw_ptr), created);
  729|      1|}
_ZN8pybind1123thread_specific_storageI3_tsEC2Ev:
  171|      1|    thread_specific_storage() {
  172|       |        // NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
  173|      1|        if (!PYBIND11_TLS_KEY_CREATE(key_)) {
  ------------------
  |  |  159|      1|#    define PYBIND11_TLS_KEY_CREATE(var) (PyThread_tss_create(&(var)) == 0)
  ------------------
  |  Branch (173:13): [True: 0, False: 1]
  ------------------
  174|      0|            pybind11_fail(
  175|      0|                "thread_specific_storage constructor: could not initialize the TSS key!");
  176|      0|        }
  177|      1|    }
_ZN8pybind1123thread_specific_storageI3_tsE3setEPS1_:
  213|      1|    void set(T *val) { PYBIND11_TLS_REPLACE_VALUE(key_, reinterpret_cast<void *>(val)); }
  ------------------
  |  |  161|      1|#    define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_tss_set(&(key), (value))
  ------------------
_ZN8pybind116detail8spinlock4lockEv:
  739|      3|    void lock() {
  740|      3|        while (flag_.test_and_set(std::memory_order_acquire)) {
  ------------------
  |  Branch (740:16): [True: 0, False: 3]
  ------------------
  741|      0|            std::this_thread::yield();
  742|      0|        }
  743|      3|    }
_ZN8pybind116detail8spinlock6unlockEv:
  744|      3|    void unlock() { flag_.clear(std::memory_order_release); }
_ZNK8pybind1123thread_specific_storageI3_tsE3getEv:
  207|  6.85k|    T *get() const { return reinterpret_cast<T *>(PYBIND11_TLS_GET_VALUE(key_)); }
  ------------------
  |  |  160|  6.85k|#    define PYBIND11_TLS_GET_VALUE(key) PyThread_tss_get(&(key))
  ------------------
_ZN8pybind116detail26get_thread_state_uncheckedEv:
  240|  6.85k|inline PyThreadState *get_thread_state_unchecked() {
  241|       |#    if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
  242|       |    return PyThreadState_GET();
  243|       |#    elif PY_VERSION_HEX < 0x030D0000
  244|       |    return _PyThreadState_UncheckedGet();
  245|       |#    else
  246|       |    return PyThreadState_GetUnchecked();
  247|       |#    endif
  248|  6.85k|}
_ZN8pybind116detail20internals_pp_managerINS0_9internalsEE5unrefEv:
  788|      1|    void unref() {
  789|       |#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
  790|       |        if (has_seen_non_main_interpreter()) {
  791|       |            last_istate_tls() = nullptr;
  792|       |            internals_p_tls() = nullptr;
  793|       |            return;
  794|       |        }
  795|       |#endif
  796|      1|        internals_singleton_pp_ = nullptr;
  797|      1|    }
_ZN8pybind116detail20internals_pp_managerINS0_15local_internalsEE5unrefEv:
  788|      1|    void unref() {
  789|       |#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
  790|       |        if (has_seen_non_main_interpreter()) {
  791|       |            last_istate_tls() = nullptr;
  792|       |            internals_p_tls() = nullptr;
  793|       |            return;
  794|       |        }
  795|       |#endif
  796|      1|        internals_singleton_pp_ = nullptr;
  797|      1|    }
_ZN8pybind116detail20internals_pp_managerINS0_9internalsEE7destroyEv:
  799|      1|    void destroy() {
  800|       |#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
  801|       |        if (has_seen_non_main_interpreter()) {
  802|       |            auto *tstate = get_thread_state_unchecked();
  803|       |            // this could be called without an active interpreter, just use what was cached
  804|       |            if (!tstate || get_interpreter(tstate) == last_istate_tls()) {
  805|       |                auto tpp = internals_p_tls();
  806|       |                {
  807|       |                    std::lock_guard<spinlock> lock(pp_set_lock_);
  808|       |                    pps_have_created_content_.erase(tpp); // untrack deleted pp
  809|       |                }
  810|       |                delete tpp; // may call back into Python
  811|       |            }
  812|       |            unref();
  813|       |            return;
  814|       |        }
  815|       |#endif
  816|      1|        {
  817|      1|            std::lock_guard<spinlock> lock(pp_set_lock_);
  818|      1|            pps_have_created_content_.erase(internals_singleton_pp_); // untrack deleted pp
  819|      1|        }
  820|      1|        delete internals_singleton_pp_; // may call back into Python
  821|      1|        unref();
  822|      1|    }
_ZN8pybind116detail20internals_pp_managerINS0_15local_internalsEE7destroyEv:
  799|      1|    void destroy() {
  800|       |#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
  801|       |        if (has_seen_non_main_interpreter()) {
  802|       |            auto *tstate = get_thread_state_unchecked();
  803|       |            // this could be called without an active interpreter, just use what was cached
  804|       |            if (!tstate || get_interpreter(tstate) == last_istate_tls()) {
  805|       |                auto tpp = internals_p_tls();
  806|       |                {
  807|       |                    std::lock_guard<spinlock> lock(pp_set_lock_);
  808|       |                    pps_have_created_content_.erase(tpp); // untrack deleted pp
  809|       |                }
  810|       |                delete tpp; // may call back into Python
  811|       |            }
  812|       |            unref();
  813|       |            return;
  814|       |        }
  815|       |#endif
  816|      1|        {
  817|      1|            std::lock_guard<spinlock> lock(pp_set_lock_);
  818|      1|            pps_have_created_content_.erase(internals_singleton_pp_); // untrack deleted pp
  819|      1|        }
  820|      1|        delete internals_singleton_pp_; // may call back into Python
  821|      1|        unref();
  822|      1|    }

_ZN8pybind1118scoped_interpreterC2EbiPKPKcb:
  237|      1|                                bool add_program_dir_to_path = true) {
  238|      1|        initialize_interpreter(init_signal_handlers, argc, argv, add_program_dir_to_path);
  239|      1|    }
_ZN8pybind1122initialize_interpreterEbiPKPKcb:
  140|      1|                                   bool add_program_dir_to_path = true) {
  141|      1|    PyConfig config;
  142|      1|    PyConfig_InitPythonConfig(&config);
  143|       |    // See PR #4473 for background
  144|      1|    config.parse_argv = 0;
  145|       |
  146|      1|    config.install_signal_handlers = init_signal_handlers ? 1 : 0;
  ------------------
  |  Branch (146:38): [True: 1, False: 0]
  ------------------
  147|      1|    initialize_interpreter(&config, argc, argv, add_program_dir_to_path);
  148|       |
  149|       |    // There is exactly one interpreter alive currently.
  150|      1|    detail::has_seen_non_main_interpreter() = false;
  151|      1|}
_ZN8pybind1122initialize_interpreterEP8PyConfigiPKPKcb:
   96|      1|                                   bool add_program_dir_to_path = true) {
   97|      1|    detail::precheck_interpreter();
   98|      1|    PyStatus status = PyConfig_SetBytesArgv(config, argc, const_cast<char *const *>(argv));
   99|      1|    if (PyStatus_Exception(status) != 0) {
  ------------------
  |  Branch (99:9): [True: 0, False: 1]
  ------------------
  100|       |        // A failure here indicates a character-encoding failure or the python
  101|       |        // interpreter out of memory. Give up.
  102|      0|        PyConfig_Clear(config);
  103|      0|        throw std::runtime_error(PyStatus_IsError(status) != 0 ? status.err_msg
  ------------------
  |  Branch (103:34): [True: 0, False: 0]
  ------------------
  104|      0|                                                               : "Failed to prepare CPython");
  105|      0|    }
  106|      1|    status = Py_InitializeFromConfig(config);
  107|      1|    if (PyStatus_Exception(status) != 0) {
  ------------------
  |  Branch (107:9): [True: 0, False: 1]
  ------------------
  108|      0|        PyConfig_Clear(config);
  109|      0|        throw std::runtime_error(PyStatus_IsError(status) != 0 ? status.err_msg
  ------------------
  |  Branch (109:34): [True: 0, False: 0]
  ------------------
  110|      0|                                                               : "Failed to init CPython");
  111|      0|    }
  112|      1|    if (add_program_dir_to_path) {
  ------------------
  |  Branch (112:9): [True: 1, False: 0]
  ------------------
  113|       |        PyRun_SimpleString("import sys, os.path; "
  114|      1|                           "sys.path.insert(0, "
  115|      1|                           "os.path.abspath(os.path.dirname(sys.argv[0])) "
  116|      1|                           "if sys.argv and os.path.exists(sys.argv[0]) else '')");
  117|      1|    }
  118|      1|    PyConfig_Clear(config);
  119|      1|}
_ZN8pybind116detail20precheck_interpreterEv:
   85|      1|inline void precheck_interpreter() {
   86|      1|    if (Py_IsInitialized() != 0) {
  ------------------
  |  Branch (86:9): [True: 0, False: 1]
  ------------------
   87|      0|        pybind11_fail("The interpreter is already running");
   88|      0|    }
   89|      1|}
_ZN8pybind1118scoped_interpreterD2Ev:
  253|      1|    ~scoped_interpreter() {
  254|      1|        if (is_valid) {
  ------------------
  |  Branch (254:13): [True: 1, False: 0]
  ------------------
  255|      1|            finalize_interpreter();
  256|      1|        }
  257|      1|    }
_ZN8pybind1120finalize_interpreterEv:
  188|      1|inline void finalize_interpreter() {
  189|       |    // get rid of any thread-local interpreter cache that currently exists
  190|      1|    if (detail::has_seen_non_main_interpreter()) {
  ------------------
  |  Branch (190:9): [True: 0, False: 1]
  ------------------
  191|      0|        detail::get_internals_pp_manager().unref();
  192|      0|        detail::get_local_internals_pp_manager().unref();
  193|       |
  194|       |        // We know there can be no other interpreter alive now
  195|      0|        detail::has_seen_non_main_interpreter() = false;
  196|      0|    }
  197|       |
  198|       |    // Re-fetch the internals pointer-to-pointer (but not the internals itself, which might not
  199|       |    // exist). It's possible for the  internals to be created during Py_Finalize() (e.g. if a
  200|       |    // py::capsule calls `get_internals()` during destruction), so we get the pointer-pointer here
  201|       |    // and check it after Py_Finalize().
  202|      1|    detail::get_internals_pp_manager().get_pp();
  203|      1|    detail::get_local_internals_pp_manager().get_pp();
  204|       |
  205|      1|    Py_Finalize();
  206|       |
  207|      1|    detail::get_internals_pp_manager().destroy();
  208|       |
  209|       |    // Local internals contains data managed by the current interpreter, so we must clear them to
  210|       |    // avoid undefined behaviors when initializing another interpreter
  211|      1|    detail::get_local_internals_pp_manager().destroy();
  212|       |
  213|       |    // We know there is no interpreter alive now, so we can reset the multi-flag
  214|      1|    detail::has_seen_non_main_interpreter() = false;
  215|      1|}

_ZN8pybind114execERKNS_3strENS_6objectES3_:
  106|  2.33k|inline void exec(const str &expr, object global = globals(), object local = object()) {
  107|  2.33k|    eval<eval_statements>(expr, std::move(global), std::move(local));
  108|  2.33k|}
_ZN8pybind114evalILNS_9eval_modeE2EEENS_6objectERKNS_3strES2_S2_:
   66|  2.33k|object eval(const str &expr, object global = globals(), object local = object()) {
   67|  2.33k|    if (!local) {
  ------------------
  |  Branch (67:9): [True: 0, False: 2.33k]
  ------------------
   68|      0|        local = global;
   69|      0|    }
   70|       |
   71|  2.33k|    detail::ensure_builtins_in_globals(global);
   72|       |
   73|       |    // PyRun_String requires a plain C string; Python 3 always assumes UTF-8 source.
   74|  2.33k|    std::string buffer = (std::string) expr;
   75|       |
   76|  2.33k|    int start = 0;
   77|  2.33k|    switch (mode) {
   78|      0|        case eval_expr:
  ------------------
  |  Branch (78:9): [True: 0, False: 2.33k]
  ------------------
   79|      0|            start = Py_eval_input;
   80|      0|            break;
   81|      0|        case eval_single_statement:
  ------------------
  |  Branch (81:9): [True: 0, False: 2.33k]
  ------------------
   82|      0|            start = Py_single_input;
   83|      0|            break;
   84|  2.33k|        case eval_statements:
  ------------------
  |  Branch (84:9): [True: 2.33k, False: 0]
  ------------------
   85|  2.33k|            start = Py_file_input;
   86|  2.33k|            break;
   87|      0|        default:
  ------------------
  |  Branch (87:9): [True: 0, False: 2.33k]
  ------------------
   88|      0|            pybind11_fail("invalid evaluation mode");
   89|  2.33k|    }
   90|       |
   91|  2.33k|    PyObject *result
   92|  2.33k|        = detail::run_string(buffer.c_str(), "<string>", start, global.ptr(), local.ptr());
   93|  2.33k|    if (!result) {
  ------------------
  |  Branch (93:9): [True: 1.93k, False: 398]
  ------------------
   94|  1.93k|        throw error_already_set();
   95|  1.93k|    }
   96|    398|    return reinterpret_steal<object>(result);
   97|  2.33k|}
_ZN8pybind116detail26ensure_builtins_in_globalsERNS_6objectE:
   21|  2.33k|inline void ensure_builtins_in_globals(object &global) {
   22|       |#if defined(PYPY_VERSION) || defined(Py_LIMITED_API)
   23|       |    // Running exec and eval adds `builtins` module under `__builtins__` key to
   24|       |    // globals if not yet present.  Python 3.8 made PyRun_String behave
   25|       |    // similarly. Let's also do that for older versions, for consistency. This
   26|       |    // was missing from PyPy3.8 7.3.7, and PyEval_EvalCode (the stable-ABI path
   27|       |    // below) does not do it either.
   28|       |    if (!global.contains("__builtins__"))
   29|       |        global["__builtins__"] = module_::import(PYBIND11_BUILTINS_MODULE);
   30|       |#else
   31|  2.33k|    (void) global;
   32|  2.33k|#endif
   33|  2.33k|}
_ZN8pybind116detail10run_stringEPKcS2_iP7_objectS4_:
   47|  2.33k|    const char *source, const char * /*filename*/, int start, PyObject *global, PyObject *local) {
   48|       |    return PyRun_String(source, start, global, local);
   49|  2.33k|}

_ZN8pybind1118gil_scoped_acquireC2Ev:
   25|  6.85k|PYBIND11_NOINLINE_ATTR PYBIND11_INLINE gil_scoped_acquire::gil_scoped_acquire() {
   26|  6.85k|    auto &internals = detail::get_internals();
   27|  6.85k|    tstate = internals.tstate.get();
   28|       |
   29|  6.85k|    if (!tstate) {
  ------------------
  |  Branch (29:9): [True: 6.85k, False: 0]
  ------------------
   30|       |        /* Check if the GIL was acquired using the PyGILState_* API instead (e.g. if
   31|       |           calling from a Python thread). Since we use a different key, this ensures
   32|       |           we don't create a new thread state and deadlock in PyEval_AcquireThread
   33|       |           below. Note we don't save this state with internals.tstate, since we don't
   34|       |           create it we would fail to clear it (its reference count should be > 0). */
   35|  6.85k|        tstate = PyGILState_GetThisThreadState();
   36|  6.85k|    }
   37|       |
   38|  6.85k|    if (!tstate) {
  ------------------
  |  Branch (38:9): [True: 0, False: 6.85k]
  ------------------
   39|      0|        tstate = PyThreadState_New(internals.istate);
   40|       |#    if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
   41|       |        if (!tstate) {
   42|       |            pybind11_fail("scoped_acquire: could not create thread state!");
   43|       |        }
   44|       |#    endif
   45|      0|        tstate->gilstate_counter = 0;
   46|      0|        internals.tstate = tstate;
   47|  6.85k|    } else {
   48|  6.85k|        release = detail::get_thread_state_unchecked() != tstate;
   49|  6.85k|    }
   50|       |
   51|  6.85k|    if (release) {
  ------------------
  |  Branch (51:9): [True: 0, False: 6.85k]
  ------------------
   52|      0|        PyEval_AcquireThread(tstate);
   53|      0|    }
   54|       |
   55|  6.85k|    inc_ref();
   56|  6.85k|}
_ZN8pybind1118gil_scoped_acquireD2Ev:
   87|  6.85k|PYBIND11_NOINLINE_ATTR PYBIND11_INLINE gil_scoped_acquire::~gil_scoped_acquire() {
   88|  6.85k|    dec_ref();
   89|  6.85k|    if (release) {
  ------------------
  |  Branch (89:9): [True: 0, False: 6.85k]
  ------------------
   90|      0|        PyEval_SaveThread();
   91|      0|    }
   92|  6.85k|}
_ZN8pybind1118gil_scoped_acquire7dec_refEv:
   58|  6.85k|PYBIND11_NOINLINE_ATTR PYBIND11_INLINE void gil_scoped_acquire::dec_ref() {
   59|  6.85k|    --tstate->gilstate_counter;
   60|       |#    if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
   61|       |    if (detail::get_thread_state_unchecked() != tstate) {
   62|       |        pybind11_fail("scoped_acquire::dec_ref(): thread state must be current!");
   63|       |    }
   64|       |    if (tstate->gilstate_counter < 0) {
   65|       |        pybind11_fail("scoped_acquire::dec_ref(): reference count underflow!");
   66|       |    }
   67|       |#    endif
   68|  6.85k|    if (tstate->gilstate_counter == 0) {
  ------------------
  |  Branch (68:9): [True: 0, False: 6.85k]
  ------------------
   69|       |#    if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
   70|       |        if (!release) {
   71|       |            pybind11_fail("scoped_acquire::dec_ref(): internal error!");
   72|       |        }
   73|       |#    endif
   74|       |        // Make sure that PyThreadState_Clear is not recursively called by finalizers.
   75|       |        // See issue #5827
   76|      0|        ++tstate->gilstate_counter;
   77|      0|        PyThreadState_Clear(tstate);
   78|      0|        --tstate->gilstate_counter;
   79|      0|        if (active) {
  ------------------
  |  Branch (79:13): [True: 0, False: 0]
  ------------------
   80|      0|            PyThreadState_DeleteCurrent();
   81|      0|        }
   82|      0|        detail::get_internals().tstate.reset();
   83|      0|        release = false;
   84|      0|    }
   85|  6.85k|}

_ZN8pybind1118gil_scoped_acquire7inc_refEv:
   74|  6.85k|    void inc_ref() { ++tstate->gilstate_counter; }

_ZN8pybind1125gil_scoped_acquire_simpleC2Ev:
   17|      3|    gil_scoped_acquire_simple() : state{PyGILState_Ensure()} {}
_ZN8pybind1125gil_scoped_acquire_simpleD2Ev:
   20|      3|    ~gil_scoped_acquire_simple() { PyGILState_Release(state); }

_ZN8pybind1117error_already_setC2Ev:
  420|  6.85k|    : m_fetched_error{new detail::error_fetch_and_normalize("pybind11::error_already_set"),
  421|  6.85k|                      m_fetched_error_deleter} {}
_ZN8pybind1117error_already_set23m_fetched_error_deleterEPNS_6detail25error_fetch_and_normalizeE:
  424|  6.85k|error_already_set::m_fetched_error_deleter(detail::error_fetch_and_normalize *raw_ptr) {
  425|  6.85k|    gil_scoped_acquire gil;
  426|  6.85k|    error_scope scope;
  427|  6.85k|    delete raw_ptr;
  428|  6.85k|}
_ZN8pybind117globalsEv:
  251|  2.33k|PYBIND11_INLINE dict globals() {
  252|       |#if PYBIND11_API_VERSION_HEX >= 0x030d0000
  253|       |    PyObject *p = PyEval_GetFrameGlobals();
  254|       |    return p ? reinterpret_steal<dict>(p)
  255|       |             : reinterpret_borrow<dict>(module_::import("__main__").attr("__dict__").ptr());
  256|       |#else
  257|  2.33k|    PyObject *p = PyEval_GetGlobals();
  258|  2.33k|    return reinterpret_borrow<dict>(p ? p : module_::import("__main__").attr("__dict__").ptr());
  ------------------
  |  Branch (258:37): [True: 0, False: 2.33k]
  ------------------
  259|  2.33k|#endif
  260|  2.33k|}
_ZN8pybind117module_6importEPKc:
 1591|  7.07k|PYBIND11_INLINE module_ module_::import(const char *name) {
 1592|  7.07k|    PyObject *obj = PyImport_ImportModule(name);
 1593|  7.07k|    if (!obj) {
  ------------------
  |  Branch (1593:9): [True: 0, False: 7.07k]
  ------------------
 1594|      0|        throw error_already_set();
 1595|      0|    }
 1596|  7.07k|    return reinterpret_steal<module_>(obj);
 1597|  7.07k|}

_ZN8pybind116detail25error_fetch_and_normalizeC2EPKc:
   24|  6.85k|PYBIND11_INLINE error_fetch_and_normalize::error_fetch_and_normalize(const char *called) {
   25|  6.85k|    PyErr_Fetch(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
   26|  6.85k|    if (!m_type) {
  ------------------
  |  Branch (26:9): [True: 0, False: 6.85k]
  ------------------
   27|      0|        pybind11_fail("Internal error: " + std::string(called)
   28|      0|                      + " called while "
   29|      0|                        "Python error indicator not set.");
   30|      0|    }
   31|  6.85k|    constexpr const char *exc_type_name_unavailable = "<EXCEPTION TYPE NAME UNAVAILABLE>";
   32|  6.85k|    m_lazy_error_string = detail::obj_class_name(m_type.ptr());
   33|  6.85k|    if (m_lazy_error_string.empty()) {
  ------------------
  |  Branch (33:9): [True: 0, False: 6.85k]
  ------------------
   34|       |        // A missing display name must not prevent reporting or restoring the primary error.
   35|      0|        m_lazy_error_string = exc_type_name_unavailable;
   36|      0|    }
   37|       |#if PY_VERSION_HEX >= 0x030C0000
   38|       |    // The presence of __notes__ is likely due to exception normalization
   39|       |    // errors, although that is not necessarily true, therefore insert a
   40|       |    // hint only:
   41|       |    const int has_notes = PyObject_HasAttrString(m_value.ptr(), "__notes__");
   42|       |    if (has_notes == 1) {
   43|       |        m_lazy_error_string += "[WITH __notes__]";
   44|       |    } else if (has_notes == -1) {
   45|       |        // Ignore secondary errors when probing for __notes__ to avoid leaking a
   46|       |        // spurious exception while still reporting the original error.
   47|       |        PyErr_Clear();
   48|       |    }
   49|       |#else
   50|       |    // PyErr_NormalizeException() may change the exception type if there are cascading
   51|       |    // failures. This can potentially be extremely confusing.
   52|  6.85k|    const object exc_type_orig = m_type;
   53|  6.85k|    PyErr_NormalizeException(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
   54|  6.85k|    if (m_type.ptr() == nullptr) {
  ------------------
  |  Branch (54:9): [True: 0, False: 6.85k]
  ------------------
   55|      0|        pybind11_fail("Internal error: " + std::string(called)
   56|      0|                      + " failed to normalize the "
   57|      0|                        "active exception.");
   58|      0|    }
   59|       |    // Detect a type replacement independently of whether its display name is available.
   60|  6.85k|    if (exc_type_orig.ptr() != m_type.ptr()) {
  ------------------
  |  Branch (60:9): [True: 0, False: 6.85k]
  ------------------
   61|      0|        std::string exc_type_name_norm = detail::obj_class_name(m_type.ptr());
   62|      0|        if (exc_type_name_norm.empty()) {
  ------------------
  |  Branch (62:13): [True: 0, False: 0]
  ------------------
   63|      0|            exc_type_name_norm = exc_type_name_unavailable;
   64|      0|        }
   65|      0|        std::string msg = std::string(called)
   66|      0|                          + ": MISMATCH of original and normalized "
   67|      0|                            "active exception types: ";
   68|      0|        msg += "ORIGINAL ";
   69|      0|        msg += m_lazy_error_string;
   70|      0|        msg += " REPLACED BY ";
   71|      0|        msg += exc_type_name_norm;
   72|      0|        msg += ": " + format_value_and_trace();
   73|      0|        pybind11_fail(msg);
   74|      0|    }
   75|  6.85k|#endif
   76|  6.85k|}

_ZNKR8pybind116handle7inc_refEv:
  306|  20.9k|    const handle &inc_ref() const & {
  307|       |#ifdef PYBIND11_HANDLE_REF_DEBUG
  308|       |        inc_ref_counter(1);
  309|       |#endif
  310|       |#ifdef PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
  311|       |        if (m_ptr != nullptr && PyGILState_Check() == 0) {
  312|       |            throw_gilstate_error("pybind11::handle::inc_ref()");
  313|       |        }
  314|       |#endif
  315|       |        Py_XINCREF(m_ptr);
  316|  20.9k|        return *this;
  317|  20.9k|    }
_ZNK8pybind116handle3ptrEv:
  298|  11.5k|    PyObject *ptr() const { return m_ptr; }
_ZN8pybind1118reinterpret_borrowINS_4dictEEET_NS_6handleE:
  515|  2.33k|T reinterpret_borrow(handle h) {
  516|  2.33k|    return {h, object::borrowed_t{}};
  517|  2.33k|}
_ZN8pybind114dictC2ENS_6handleENS_6object10borrowed_tE:
 1460|  2.33k|    Name(handle h, borrowed_t) : Parent(h, borrowed_t{}) {}                                       \
_ZN8pybind116objectC2ENS_6handleENS0_10borrowed_tE:
  497|  4.73k|    object(handle h, borrowed_t) : handle(h) { inc_ref(); }
_ZN8pybind116objectC2Ev:
  414|  27.6k|    object() = default;
_ZN8pybind116handleC2Ev:
  278|  34.7k|    handle() = default;
_ZN8pybind1118reinterpret_borrowINS_6objectEEET_NS_6handleE:
  515|      2|T reinterpret_borrow(handle h) {
  516|      2|    return {h, object::borrowed_t{}};
  517|      2|}
_ZN8pybind116handleC2IP7_objectTnNSt3__19enable_ifIXsr6detail25is_pyobj_ptr_or_nullptr_tIT_EE5valueEiE4typeELi0EEES6_:
  285|  49.9k|    handle(T ptr) : m_ptr(ptr) {}
_ZN8pybind116objectaSEOS0_:
  452|  7.03k|    object &operator=(object &&other) noexcept {
  453|  7.03k|        if (this != &other) {
  ------------------
  |  Branch (453:13): [True: 7.03k, False: 0]
  ------------------
  454|  7.03k|            handle temp(m_ptr);
  455|  7.03k|            m_ptr = other.m_ptr;
  456|  7.03k|            other.m_ptr = nullptr;
  457|  7.03k|            temp.dec_ref();
  458|  7.03k|        }
  459|  7.03k|        return *this;
  460|  7.03k|    }
_ZNKR8pybind116handle7dec_refEv:
  324|   103k|    const handle &dec_ref() const & {
  325|       |#ifdef PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
  326|       |        if (m_ptr != nullptr && PyGILState_Check() == 0) {
  327|       |            throw_gilstate_error("pybind11::handle::dec_ref()");
  328|       |        }
  329|       |#endif
  330|       |        Py_XDECREF(m_ptr);
  331|   103k|        return *this;
  332|   103k|    }
_ZNK8pybind116handlecvbEv:
  341|  32.7k|    explicit operator bool() const { return m_ptr != nullptr; }
_ZN8pybind116objectD2Ev:
  426|  96.1k|    ~object() { dec_ref(); }
_ZN8pybind116detail18dict_getitemstringEP7_objectPKc:
  927|      2|inline PyObject *dict_getitemstring(PyObject *v, const char *key) {
  928|      2|    PyObject *kv = nullptr, *rv = nullptr;
  929|      2|    kv = PyUnicode_FromString(key);
  930|      2|    if (kv == nullptr) {
  ------------------
  |  Branch (930:9): [True: 0, False: 2]
  ------------------
  931|      0|        throw error_already_set();
  932|      0|    }
  933|       |
  934|      2|    rv = PyDict_GetItemWithError(v, kv);
  935|      2|    Py_DECREF(kv);
  936|      2|    if (rv == nullptr && PyErr_Occurred()) {
  ------------------
  |  Branch (936:9): [True: 2, False: 0]
  |  Branch (936:26): [True: 0, False: 2]
  ------------------
  937|      0|        throw error_already_set();
  938|      0|    }
  939|      2|    return rv;
  940|      2|}
_ZN8pybind116handle3ptrEv:
  299|  96.9k|    PyObject *&ptr() { return m_ptr; }
_ZN8pybind116detail14obj_class_nameEP7_object:
  651|  6.85k|inline std::string obj_class_name(PyObject *obj) {
  652|  6.85k|    if (PyType_Check(obj)) {
  ------------------
  |  Branch (652:9): [True: 6.85k, False: 0]
  ------------------
  653|  6.85k|        return get_tp_name(reinterpret_cast<PyTypeObject *>(obj));
  654|  6.85k|    }
  655|      0|    return get_tp_name(Py_TYPE(obj));
  656|  6.85k|}
_ZN8pybind116detail11get_tp_nameEP11_typeobject:
  537|  6.85k|inline std::string get_tp_name(PyTypeObject *type) { return type->tp_name ? type->tp_name : ""; }
  ------------------
  |  Branch (537:61): [True: 6.85k, False: 0]
  ------------------
_ZN8pybind116objectC2ERKS0_:
  422|  13.8k|    object(const object &o) : handle(o) { inc_ref(); }
_ZN8pybind1117reinterpret_stealINS_6objectEEET_NS_6handleE:
  528|  12.1k|T reinterpret_steal(handle h) {
  529|  12.1k|    return {h, object::stolen_t{}};
  530|  12.1k|}
_ZN8pybind116objectC2ENS_6handleENS0_8stolen_tE:
  498|  35.8k|    object(handle h, stolen_t) : handle(h) {}
_ZNK8pybind116detail10object_apiINS_6handleEE7derivedEv:
  108|  9.43k|    const Derived &derived() const { return static_cast<const Derived &>(*this); }
_ZN8pybind117capsuleC2EPKvPFvPvE:
 2074|      2|    capsule(const void *value, void (*destructor)(void *)) {
 2075|      2|        initialize_with_void_ptr_destructor(value, nullptr, destructor);
 2076|      2|    }
_ZN8pybind117capsule35initialize_with_void_ptr_destructorEPKvPKcPFvPvE:
 2150|      2|                                             void (*destructor)(void *)) {
 2151|      2|        m_ptr = PyCapsule_New(const_cast<void *>(value), name, [](PyObject *o) {
 2152|       |            // guard if destructor called while err indicator is set
 2153|      2|            error_scope error_guard;
 2154|      2|            auto destructor = reinterpret_cast<void (*)(void *)>(PyCapsule_GetContext(o));
 2155|      2|            if (destructor == nullptr && PyErr_Occurred()) {
 2156|      2|                throw error_already_set();
 2157|      2|            }
 2158|      2|            const char *name = get_name_in_error_scope(o);
 2159|      2|            void *ptr = PyCapsule_GetPointer(o, name);
 2160|      2|            if (ptr == nullptr) {
 2161|      2|                throw error_already_set();
 2162|      2|            }
 2163|       |
 2164|      2|            if (destructor != nullptr) {
 2165|      2|                destructor(ptr);
 2166|      2|            }
 2167|      2|        });
 2168|       |
 2169|      2|        if (!m_ptr || PyCapsule_SetContext(m_ptr, reinterpret_cast<void *>(destructor)) != 0) {
  ------------------
  |  Branch (2169:13): [True: 0, False: 2]
  |  Branch (2169:23): [True: 0, False: 2]
  ------------------
 2170|      0|            throw error_already_set();
 2171|      0|        }
 2172|      2|    }
_ZN8pybind116detail21dict_setdefaultstringEP7_objectPKcS2_:
  987|      2|inline PyObject *dict_setdefaultstring(PyObject *v, const char *key, PyObject *defaultobj) {
  988|      2|    PyObject *kv = PyUnicode_FromString(key);
  989|      2|    if (kv == nullptr) {
  ------------------
  |  Branch (989:9): [True: 0, False: 2]
  ------------------
  990|      0|        throw error_already_set();
  991|      0|    }
  992|       |
  993|      2|#if !defined(Py_LIMITED_API)
  994|      2|    PyObject *rv = PyDict_SetDefault(v, kv, defaultobj);
  995|       |#else
  996|       |    // dict.setdefault() is one C-level call, so it is just as atomic as PyDict_SetDefault.
  997|       |    PyObject *rv = PyObject_CallMethod(v, "setdefault", "OO", kv, defaultobj);
  998|       |    Py_XDECREF(rv);
  999|       |#endif
 1000|      2|    Py_DECREF(kv);
 1001|      2|    if (rv == nullptr) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 2]
  ------------------
 1002|      0|        throw error_already_set();
 1003|      0|    }
 1004|      2|    return rv;
 1005|      2|}
_ZN8pybind117setattrENS_6handleEPKcS0_:
  876|      3|inline void setattr(handle obj, const char *name, handle value) {
  877|      3|    if (PyObject_SetAttrString(obj.ptr(), name, value.ptr()) != 0) {
  ------------------
  |  Branch (877:9): [True: 0, False: 3]
  ------------------
  878|      0|        throw error_already_set();
  879|      0|    }
  880|      3|}
_ZN8pybind113strC2EPKc:
 1649|      3|    str(const char *c = "") : object(PyUnicode_FromString(c), stolen_t{}) {
 1650|      3|        if (!m_ptr) {
  ------------------
  |  Branch (1650:13): [True: 0, False: 3]
  ------------------
 1651|      0|            if (PyErr_Occurred()) {
  ------------------
  |  Branch (1651:17): [True: 0, False: 0]
  ------------------
 1652|      0|                throw error_already_set();
 1653|      0|            }
 1654|      0|            pybind11_fail("Could not allocate string object!");
 1655|      0|        }
 1656|      3|    }
_ZN8pybind114noneC2Ev:
 1867|  2.39k|    none() : object(Py_None, borrowed_t{}) {}
_ZNK8pybind116detail10object_apiINS_6handleEE4attrEPKc:
 2641|  7.09k|str_attr_accessor object_api<D>::attr(const char *key) const {
 2642|  7.09k|    return {derived(), key};
 2643|  7.09k|}
_ZN8pybind116detail8accessorINS0_17accessor_policies8str_attrEEC2ENS_6handleEPKc:
 1054|  7.09k|    accessor(handle obj, key_type key) : obj(obj), key(std::move(key)) {}
_ZNK8pybind116detail8accessorINS0_17accessor_policies8str_attrEE9get_cacheEv:
 1100|  7.09k|    object &get_cache() const {
 1101|  7.09k|        if (!cache) {
  ------------------
  |  Branch (1101:13): [True: 7.09k, False: 0]
  ------------------
 1102|  7.09k|            cache = Policy::get(obj, key);
 1103|  7.09k|        }
 1104|  7.09k|        return cache;
 1105|  7.09k|    }
_ZN8pybind116detail17accessor_policies8str_attr3getENS_6handleEPKc:
 1123|  7.09k|    static object get(handle obj, const char *key) { return getattr(obj, key); }
_ZN8pybind117getattrENS_6handleEPKc:
  846|  7.09k|inline object getattr(handle obj, const char *name) {
  847|  7.09k|    PyObject *result = PyObject_GetAttrString(obj.ptr(), name);
  848|  7.09k|    if (!result) {
  ------------------
  |  Branch (848:9): [True: 2.38k, False: 4.70k]
  ------------------
  849|  2.38k|        throw error_already_set();
  850|  2.38k|    }
  851|  4.70k|    return reinterpret_steal<object>(result);
  852|  7.09k|}
_ZN8pybind116objectC2EOS0_:
  424|  14.0k|    object(object &&other) noexcept : handle(other) { other.m_ptr = nullptr; }
_ZN8pybind116handleC2IDnTnNSt3__19enable_ifIXsr6detail25is_pyobj_ptr_or_nullptr_tIT_EE5valueEiE4typeELi0EEES4_:
  285|  4.74k|    handle(T ptr) : m_ptr(ptr) {}
_ZN8pybind115tupleC2ImTnNSt3__19enable_ifIXsr11is_integralIT_EE5valueEiE4typeELi0EEES4_:
 2181|  2.34k|    explicit tuple(SzType size = 0) : object(PyTuple_New(ssize_t_cast(size)), stolen_t{}) {
 2182|  2.34k|        if (!m_ptr) {
  ------------------
  |  Branch (2182:13): [True: 0, False: 2.34k]
  ------------------
 2183|      0|            pybind11_fail("Could not allocate tuple object!");
 2184|      0|        }
 2185|  2.34k|    }
_ZN8pybind116detail14tuple_set_itemEP7_objectlS2_:
  630|  4.69k|inline void tuple_set_item(PyObject *tup, ssize_t i, PyObject *item) {
  631|       |    PyTuple_SET_ITEM(tup, i, item);
  632|  4.69k|}
_ZN8pybind115tupleC2EONS_6objectE:
 1478|  2.34k|    Name(object &&o) : Parent(check_(o) ? o.release().ptr() : ConvertFun(o.ptr()), stolen_t{}) {  \
  ------------------
  |  Branch (1478:31): [True: 2.34k, False: 0]
  ------------------
 1479|  2.34k|        if (!m_ptr)                                                                               \
  ------------------
  |  Branch (1479:13): [True: 0, False: 2.34k]
  ------------------
 1480|  2.34k|            throw ::pybind11::error_already_set();                                                \
 1481|  2.34k|    }
_ZN8pybind114dictC2Ev:
 2208|  2.39k|    dict() : object(PyDict_New(), stolen_t{}) {
 2209|  2.39k|        if (!m_ptr) {
  ------------------
  |  Branch (2209:13): [True: 0, False: 2.39k]
  ------------------
 2210|      0|            pybind11_fail("Could not allocate dict object!");
 2211|      0|        }
 2212|  2.39k|    }
_ZNK8pybind113strcvNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEv:
 1693|  2.33k|    operator std::string() const {
 1694|  2.33k|        object temp = *this;
 1695|  2.33k|        if (PyUnicode_Check(m_ptr)) {
  ------------------
  |  Branch (1695:13): [True: 2.33k, False: 0]
  ------------------
 1696|  2.33k|            temp = reinterpret_steal<object>(PyUnicode_AsUTF8String(m_ptr));
 1697|  2.33k|            if (!temp) {
  ------------------
  |  Branch (1697:17): [True: 0, False: 2.33k]
  ------------------
 1698|      0|                throw error_already_set();
 1699|      0|            }
 1700|  2.33k|        }
 1701|  2.33k|        char *buffer = nullptr;
 1702|  2.33k|        ssize_t length = 0;
 1703|  2.33k|        if (PyBytes_AsStringAndSize(temp.ptr(), &buffer, &length) != 0) {
  ------------------
  |  Branch (1703:13): [True: 0, False: 2.33k]
  ------------------
 1704|      0|            throw error_already_set();
 1705|      0|        }
 1706|  2.33k|        return std::string(buffer, static_cast<size_t>(length));
 1707|  2.33k|    }
_ZNK8pybind116detail8accessorINS0_17accessor_policies8str_attrEEcvNS_6objectEEv:
 1089|  4.74k|    operator object() const { return get_cache(); }
_ZN8pybind116object7releaseEv:
  433|  7.04k|    handle release() {
  434|  7.04k|        PyObject *tmp = m_ptr;
  435|  7.04k|        m_ptr = nullptr;
  436|  7.04k|        return handle(tmp);
  437|  7.04k|    }
_ZN8pybind116detail11type_lookupEP11_typeobjectNS_6handleE:
 2769|      1|inline handle type_lookup(PyTypeObject *type, handle name) {
 2770|      1|    return _PyType_Lookup(type, name.ptr());
 2771|      1|}
_ZN8pybind113strC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 1659|  4.79k|    str(const std::string &s) : str(s.data(), s.size()) {}
_ZN8pybind113strC2ImTnNSt3__19enable_ifIXsr11is_integralIT_EE5valueEiE4typeELi0EEEPKcRKS4_:
 1637|  4.79k|        : object(PyUnicode_FromStringAndSize(c, ssize_t_cast(n)), stolen_t{}) {
 1638|  4.79k|        if (!m_ptr) {
  ------------------
  |  Branch (1638:13): [True: 146, False: 4.65k]
  ------------------
 1639|    146|            if (PyErr_Occurred()) {
  ------------------
  |  Branch (1639:17): [True: 146, False: 0]
  ------------------
 1640|    146|                throw error_already_set();
 1641|    146|            }
 1642|      0|            pybind11_fail("Could not allocate string object!");
 1643|      0|        }
 1644|  4.79k|    }
_ZNK8pybind116detail8accessorINS0_17accessor_policies8str_attrEE3ptrEv:
 1090|  2.34k|    PyObject *ptr() const { return get_cache().ptr(); }
_ZN8pybind1117reinterpret_stealINS_7module_EEET_NS_6handleE:
  528|  7.07k|T reinterpret_steal(handle h) {
  529|  7.07k|    return {h, object::stolen_t{}};
  530|  7.07k|}
_ZN8pybind117module_C2ENS_6handleENS_6object8stolen_tE:
 1461|  7.07k|    Name(handle h, stolen_t) : Parent(h, stolen_t{}) {}                                           \
_ZN8pybind1117reinterpret_stealINS_5tupleEEET_NS_6handleE:
  528|  2.36k|T reinterpret_steal(handle h) {
  529|  2.36k|    return {h, object::stolen_t{}};
  530|  2.36k|}
_ZN8pybind115tupleC2ENS_6handleENS_6object8stolen_tE:
 1461|  2.36k|    Name(handle h, stolen_t) : Parent(h, stolen_t{}) {}                                           \
_ZN8pybind1117reinterpret_stealINS_4listEEET_NS_6handleE:
  528|  2.36k|T reinterpret_steal(handle h) {
  529|  2.36k|    return {h, object::stolen_t{}};
  530|  2.36k|}
_ZN8pybind114listC2ENS_6handleENS_6object8stolen_tE:
 1461|  2.36k|    Name(handle h, stolen_t) : Parent(h, stolen_t{}) {}                                           \
_ZNK8pybind116detail10object_apiINS0_8accessorINS0_17accessor_policies8str_attrEEEE7derivedEv:
  108|     13|    const Derived &derived() const { return static_cast<const Derived &>(*this); }

_ZN13pybind11_fuzz12decode_inputEPKhm:
   21|  2.39k|inline input decode_input(const std::uint8_t *data, std::size_t size) {
   22|  2.39k|    FuzzedDataProvider fdp(data, size);
   23|  2.39k|    input result;
   24|  2.39k|    result.code = fdp.ConsumeRandomLengthString();
   25|  2.39k|    result.attr_name = fdp.ConsumeRandomLengthString();
   26|  2.39k|    result.decimal_text = fdp.ConsumeRandomLengthString();
   27|  2.39k|    result.decimal_attr = fdp.ConsumeRandomLengthString();
   28|  2.39k|    result.text = fdp.ConsumeRandomLengthString();
   29|  2.39k|    return result;
   30|  2.39k|}

LLVMFuzzerTestOneInput:
   75|  2.39k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   76|  2.39k|    const auto input = pybind11_fuzz::decode_input(data, size);
   77|  2.39k|    return exercise(
   78|  2.39k|        input.code, input.attr_name, input.decimal_text, input.decimal_attr, input.text);
   79|  2.39k|}
pybind_fuzzer.cpp:_ZN12_GLOBAL__N_18exerciseERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_S8_S8_S8_:
   40|  2.39k|             const std::string &text) {
   41|  2.39k|    static interpreter guard{};
   42|  2.39k|    try {
   43|  2.39k|        auto locals = py::dict();
   44|  2.39k|        py::exec(code, py::globals(), locals);
   45|  2.39k|    } catch (const py::error_already_set &) {
   46|  2.00k|    }
   47|       |
   48|  2.39k|    try {
   49|  2.39k|        py::object os = py::module_::import("os");
   50|  2.39k|        py::object looked_up = os.attr(attr_name.c_str());
   51|  2.39k|        (void) looked_up;
   52|  2.39k|    } catch (const py::error_already_set &) {
   53|  2.37k|    }
   54|       |
   55|  2.39k|    try {
   56|  2.39k|        py::tuple args = py::make_tuple(decimal_text, py::none());
   57|  2.39k|        (void) args;
   58|  2.39k|        py::object Decimal = py::module_::import("decimal").attr("Decimal");
   59|  2.39k|        py::object pi = Decimal(decimal_text);
   60|  2.39k|        py::object called = pi.attr(decimal_attr.c_str())();
   61|  2.39k|        (void) called;
   62|  2.39k|    } catch (const py::error_already_set &) {
   63|  2.39k|    }
   64|       |
   65|  2.39k|    try {
   66|  2.39k|        py::object obj = py::str(text);
   67|  2.39k|        (void) obj;
   68|  2.39k|    } catch (const py::error_already_set &) {
   69|     80|    }
   70|  2.39k|    return 0;
   71|  2.39k|}
pybind_fuzzer.cpp:_ZN12_GLOBAL__N_111interpreterC2Ev:
   28|      1|    interpreter() {
   29|       |        // Construct both managers before this static finishes construction so
   30|       |        // they remain alive when guard finalizes the interpreter at process exit.
   31|      1|        (void) py::detail::get_internals_pp_manager();
   32|      1|        (void) py::detail::get_local_internals_pp_manager();
   33|      1|    }

