mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 23:09:13 +00:00
Fix nullptr dereference when loading an external-only module_local type
This commit is contained in:
@@ -3,6 +3,22 @@ import pytest
|
||||
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"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user