From 68b6f8c61208ded6141e3ac9f2d0f7e27771b04b Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 25 Jun 2021 18:11:06 -0700 Subject: [PATCH] Tracking change in type_caster_base.h on master (PR #3059). --- .../detail/smart_holder_type_casters.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 653332bf8..95bf79086 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -164,12 +164,6 @@ public: PYBIND11_NOINLINE bool load_impl(handle src, bool convert) { if (!src) return false; if (!typeinfo) return try_load_foreign_module_local(src); - if (src.is_none()) { - // Defer accepting None to other overloads (if we aren't in convert mode): - if (!convert) return false; - loaded_v_h = value_and_holder(); - return true; - } auto &this_ = static_cast(*this); @@ -242,7 +236,17 @@ public: } // Global typeinfo has precedence over foreign module_local - return try_load_foreign_module_local(src); + if (try_load_foreign_module_local(src)) + return true; + + if (src.is_none()) { + // Defer accepting None to other overloads (if we aren't in convert mode): + if (!convert) return false; + loaded_v_h = value_and_holder(); + return true; + } + + return false; } const type_info *typeinfo = nullptr;