diff --git a/CHANGES/927.bugfix.rst b/CHANGES/927.bugfix.rst new file mode 100644 index 00000000..884a735d --- /dev/null +++ b/CHANGES/927.bugfix.rst @@ -0,0 +1,2 @@ +Fixed a ``SystemError: null argument to internal routine`` error on +a ``MultiDict.items().isdisjoint()`` call when using C Extensions. diff --git a/multidict/_multilib/views.h b/multidict/_multilib/views.h index ad94b21b..ec80e07a 100644 --- a/multidict/_multilib/views.h +++ b/multidict/_multilib/views.h @@ -409,7 +409,7 @@ multidict_views_init(void) GET_MOD_ATTR(abc_keysview_register_func, "_abc_keysview_register"); GET_MOD_ATTR(abc_valuesview_register_func, "_abc_valuesview_register"); - GET_MOD_ATTR(itemsview_repr_func, "_itemsview_isdisjoint"); + GET_MOD_ATTR(itemsview_isdisjoint_func, "_itemsview_isdisjoint"); GET_MOD_ATTR(itemsview_repr_func, "_itemsview_repr"); GET_MOD_ATTR(keysview_repr_func, "_keysview_repr"); diff --git a/tests/test_multidict.py b/tests/test_multidict.py index 0f2d0614..4012a569 100644 --- a/tests/test_multidict.py +++ b/tests/test_multidict.py @@ -417,13 +417,16 @@ def test_xor2(self, cls: Type[MutableMultiMapping[str]]) -> None: assert {"key", "key3"} == {"key2", "key3"} ^ d.keys() - @pytest.mark.parametrize(("set_", "expected"), (({"key2"}, True), ({"key"}, False))) + @pytest.mark.parametrize( + ("key", "value", "expected"), + (("key2", "v", True), ("key", "value1", False)), + ) def test_isdisjoint( - self, cls: Type[MutableMultiMapping[str]], set_: Set[str], expected: bool + self, cls: Type[MutableMultiMapping[str]], key: str, value: str, expected: bool ) -> None: d = cls([("key", "value1")]) - - assert d.keys().isdisjoint(set_) == expected + assert d.items().isdisjoint({(key, value)}) is expected + assert d.keys().isdisjoint({key}) is expected def test_repr_aiohttp_issue_410(self, cls: Type[MutableMultiMapping[str]]) -> None: d = cls()