Skip to content
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: 1 addition & 1 deletion mypyc/lib-rt/misc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ int CPyStatics_Initialize(PyObject **statics,
}
for (int i = 0; i < num_items; i++) {
PyObject *item = statics[*frozensets++];
Py_INCREF(item);
if (PySet_Add(obj, item) == -1) {
Py_DECREF(obj);
return -1;
}
}
Expand Down
8 changes: 8 additions & 0 deletions mypyc/test-data/run-sets.test
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ update(s, [5, 4, 3])
assert s == {1, 2, 3, 4, 5}

[case testFrozenSets]
import sys
from typing import FrozenSet, List, Any, cast
from testutil import assertRaises

Expand Down Expand Up @@ -183,6 +184,13 @@ def test_frozen_sets() -> None:
with assertRaises(TypeError, "frozenset object expected; got set"):
castFrozenSetError()

value = b'frozenset member'
assert value in {b'frozenset member', b'other member'}
# References from the statics array, the precomputed frozenset, and the
# getrefcount argument. The compiled local borrows its reference.
getrefcount: Any = getattr(sys, "getrefcount")
assert getrefcount(value) == 3, getrefcount(value)

[case testFrozenSetsFromIterables]
from typing import FrozenSet

Expand Down
Loading