Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultiDict.items().isdisjoint() for C Extensions #927

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/927.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a ``SystemError: null argument to internal routine`` error on
a ``MultiDict.items().isdisjoint()`` call when using C Extensions.
2 changes: 1 addition & 1 deletion multidict/_multilib/views.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 7 additions & 4 deletions tests/test_multidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading