Fix nullptr dereference when loading an external-only module_local type
diff --git a/tests/test_local_bindings.py b/tests/test_local_bindings.py
index e9a63ca..b3dc361 100644
--- a/tests/test_local_bindings.py
+++ b/tests/test_local_bindings.py
@@ -3,6 +3,22 @@
 from pybind11_tests import local_bindings as m
 
 
+def test_load_external():
+    """Load a `py::module_local` type that's only registered in an external module"""
+    import pybind11_cross_module_tests as cm
+
+    assert m.load_external1(cm.ExternalType1(11)) == 11
+    assert m.load_external2(cm.ExternalType2(22)) == 22
+
+    with pytest.raises(TypeError) as excinfo:
+        assert m.load_external2(cm.ExternalType1(21)) == 21
+    assert "incompatible function arguments" in str(excinfo.value)
+
+    with pytest.raises(TypeError) as excinfo:
+        assert m.load_external1(cm.ExternalType2(12)) == 12
+    assert "incompatible function arguments" in str(excinfo.value)
+
+
 def test_local_bindings():
     """Tests that duplicate `py::module_local` class bindings work across modules"""