Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 12 additions & 1 deletion Lib/test/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ def test_symmetric_difference(self):
self.assertEqual(type(i), self.basetype)
self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference, [[]])
for C in set, frozenset, dict.fromkeys, str, list, tuple:
constructors = (set, frozenset,
dict.fromkeys, frozendict.fromkeys,
str, list, tuple)
for C in constructors:
self.assertEqual(self.thetype('abcba').symmetric_difference(C('cdc')), set('abd'))
self.assertEqual(self.thetype('abcba').symmetric_difference(C('efgfe')), set('abcefg'))
self.assertEqual(self.thetype('abcba').symmetric_difference(C('ccb')), set('a'))
Expand Down Expand Up @@ -1591,6 +1594,14 @@ def setUp(self):

#------------------------------------------------------------------------------

class TestOnlySetsFrozenDict(TestOnlySetsInBinaryOps, unittest.TestCase):
def setUp(self):
self.set = set((1, 2, 3))
self.other = frozendict({1:2, 3:4})
self.otherIsIterable = True

#------------------------------------------------------------------------------

class TestOnlySetsOperator(TestOnlySetsInBinaryOps, unittest.TestCase):
def setUp(self):
self.set = set((1, 2, 3))
Expand Down
14 changes: 7 additions & 7 deletions Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ set_iter(PyObject *so)
static int
set_update_dict_lock_held(PySetObject *so, PyObject *other)
{
assert(PyDict_CheckExact(other));
assert(PyAnyDict_CheckExact(other));

_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(so);
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(other);
Expand Down Expand Up @@ -1242,7 +1242,7 @@ set_update_lock_held(PySetObject *so, PyObject *other)
if (PyAnySet_Check(other)) {
return set_merge_lock_held(so, other);
}
else if (PyDict_CheckExact(other)) {
else if (PyAnyDict_CheckExact(other)) {
return set_update_dict_lock_held(so, other);
}
return set_update_iterable_lock_held(so, other);
Expand All @@ -1260,7 +1260,7 @@ set_update_local(PySetObject *so, PyObject *other)
Py_END_CRITICAL_SECTION();
return rv;
}
else if (PyDict_CheckExact(other)) {
else if (PyAnyDict_CheckExact(other)) {
int rv;
Py_BEGIN_CRITICAL_SECTION(other);
rv = set_update_dict_lock_held(so, other);
Expand All @@ -1283,7 +1283,7 @@ set_update_internal(PySetObject *so, PyObject *other)
Py_END_CRITICAL_SECTION2();
return rv;
}
else if (PyDict_CheckExact(other)) {
else if (PyAnyDict_CheckExact(other)) {
int rv;
Py_BEGIN_CRITICAL_SECTION2(so, other);
rv = set_update_dict_lock_held(so, other);
Expand Down Expand Up @@ -2030,7 +2030,7 @@ set_difference(PySetObject *so, PyObject *other)
if (PyAnySet_Check(other)) {
other_size = PySet_GET_SIZE(other);
}
else if (PyDict_CheckExact(other)) {
else if (PyAnyDict_CheckExact(other)) {
other_size = PyDict_GET_SIZE(other);
}
else {
Expand All @@ -2047,7 +2047,7 @@ set_difference(PySetObject *so, PyObject *other)
if (result == NULL)
return NULL;

if (PyDict_CheckExact(other)) {
if (PyAnyDict_CheckExact(other)) {
while (set_next(so, &pos, &entry)) {
key = entry->key;
hash = entry->hash;
Expand Down Expand Up @@ -2238,7 +2238,7 @@ set_symmetric_difference_update_impl(PySetObject *so, PyObject *other)
}

int rv;
if (PyDict_CheckExact(other)) {
if (PyAnyDict_CheckExact(other)) {
Py_BEGIN_CRITICAL_SECTION2(so, other);
rv = set_symmetric_difference_update_dict(so, other);
Py_END_CRITICAL_SECTION2();
Expand Down
Loading