mirror of https://github.com/python/cpython
Issue #7818: set().test_c_api() doesn't expect a set('abc'), modify the set.
This commit is contained in:
parent
f1539bd4fc
commit
17d905449d
|
@ -562,7 +562,7 @@ class TestSet(TestJointOps):
|
|||
# C API test only available in a debug build
|
||||
if hasattr(set, "test_c_api"):
|
||||
def test_c_api(self):
|
||||
self.assertEqual(set('abc').test_c_api(), True)
|
||||
self.assertEqual(set().test_c_api(), True)
|
||||
|
||||
class SetSubclass(set):
|
||||
pass
|
||||
|
|
|
@ -2387,11 +2387,25 @@ test_c_api(PySetObject *so)
|
|||
Py_ssize_t i;
|
||||
PyObject *elem=NULL, *dup=NULL, *t, *f, *dup2, *x;
|
||||
PyObject *ob = (PyObject *)so;
|
||||
PyObject *str;
|
||||
|
||||
/* Verify preconditions and exercise type/size checks */
|
||||
/* Verify preconditions */
|
||||
assert(PyAnySet_Check(ob));
|
||||
assert(PyAnySet_CheckExact(ob));
|
||||
assert(!PyFrozenSet_CheckExact(ob));
|
||||
|
||||
/* so.clear(); so |= set("abc"); */
|
||||
str = PyString_FromString("abc");
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
set_clear_internal(so);
|
||||
if (set_update_internal(so, str) == -1) {
|
||||
Py_DECREF(str);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(str);
|
||||
|
||||
/* Exercise type/size checks */
|
||||
assert(PySet_Size(ob) == 3);
|
||||
assert(PySet_GET_SIZE(ob) == 3);
|
||||
|
||||
|
|
Loading…
Reference in New Issue