Skip to content

Commit 6bb0d58

Browse files
eendebakptvstinner
andauthored
Apply suggestions from code review
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent ff61155 commit 6bb0d58

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Modules/_testlimitedcapi/set.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ test_frozenset_add_in_capi(PyObject *self, PyObject *Py_UNUSED(obj))
158158
static PyObject *
159159
raiseTestError(const char* test_name, const char* msg)
160160
{
161-
PyObject *exc = PyErr_GetRaisedException();
162-
PyErr_Format(exc, "%s: %s", test_name, msg);
161+
PyErr_Format(PyExc_AssertionError, "%s: %s", test_name, msg);
163162
return NULL;
164163
}
165164

Objects/setobject.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,8 @@ make_new_set_basetype(PyTypeObject *type, PyObject *iterable)
13681368
return make_new_set(type, iterable);
13691369
}
13701370

1371-
void
13721371
// gh-140232: check whether a frozenset can be untracked from the GC
1372+
void
13731373
_PyFrozenSet_MaybeUntrack(PyObject *op)
13741374
{
13751375
assert(op != NULL);
@@ -2957,7 +2957,7 @@ PyObject *
29572957
PyFrozenSet_New(PyObject *iterable)
29582958
{
29592959
PyObject *result = make_new_set(&PyFrozenSet_Type, iterable);
2960-
if (result != 0) {
2960+
if (result != NULL) {
29612961
_PyFrozenSet_MaybeUntrack(result);
29622962
}
29632963
return result;
@@ -3038,8 +3038,9 @@ PySet_Add(PyObject *anyset, PyObject *key)
30383038
// API limits the usage of `PySet_Add` to "fill in the values of brand
30393039
// new frozensets before they are exposed to other code". In this case,
30403040
// this can be done without a lock.
3041-
// since another key is added to the set, we must track the frozenset if needed
3042-
if (PyFrozenSet_CheckExact(anyset) && PyObject_GC_IsTracked(key) && !PyObject_GC_IsTracked(anyset) ) {
3041+
// Since another key is added to the set, we must track the frozenset
3042+
// if needed.
3043+
if (PyFrozenSet_CheckExact(anyset) && PyObject_GC_IsTracked(key) && !PyObject_GC_IsTracked(anyset)) {
30433044
_PyObject_GC_TRACK(anyset);
30443045
}
30453046
return set_add_key((PySetObject *)anyset, key);

0 commit comments

Comments
 (0)