Skip to content

Commit d3b0e31

Browse files
Revert for asserts
1 parent 2989918 commit d3b0e31

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ CDataType_from_buffer_copy_impl(PyObject *type, PyTypeObject *cls,
987987

988988
result = generic_pycdata_new(st, (PyTypeObject *)type, NULL, NULL);
989989
if (result != NULL) {
990-
assert(_PyObject_IsUniquelyReferenced(result));
990+
assert(Py_REFCNT(result) == 1);
991991
memcpy(((CDataObject *) result)->b_ptr, (char *)buffer->buf + offset, info->size);
992992
}
993993
return result;

Modules/_functoolsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ _functools_reduce_impl(PyObject *module, PyObject *func, PyObject *seq,
10931093
result = op2;
10941094
else {
10951095
/* Update the args tuple in-place */
1096-
assert(_PyObject_IsUniquelyReferenced(args));
1096+
assert(Py_REFCNT(args) == 1);
10971097
Py_XSETREF(_PyTuple_ITEMS(args)[0], result);
10981098
Py_XSETREF(_PyTuple_ITEMS(args)[1], op2);
10991099
if ((result = PyObject_Call(func, args, NULL)) == NULL) {

Modules/itertoolsmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,7 @@ product_next_lock_held(PyObject *op)
21432143
_PyTuple_Recycle(result);
21442144
}
21452145
/* Now, we've got the only copy so we can update it in-place */
2146-
assert (npools==0 || _PyObject_IsUniquelyReferenced(result));
2146+
assert (npools==0 || Py_REFCNT(result) == 1);
21472147

21482148
/* Update the pool indices right-to-left. Only advance to the
21492149
next pool when the previous one rolls-over */
@@ -2381,7 +2381,7 @@ combinations_next_lock_held(PyObject *op)
23812381
* CPython's empty tuple is a singleton and cached in
23822382
* PyTuple's freelist.
23832383
*/
2384-
assert(r == 0 || _PyObject_IsUniquelyReferenced(result));
2384+
assert(r == 0 || Py_REFCNT(result) == 1);
23852385

23862386
/* Scan indices right-to-left until finding one that is not
23872387
at its maximum (i + n - r). */
@@ -2633,7 +2633,7 @@ cwr_next(PyObject *op)
26332633
}
26342634
/* Now, we've got the only copy so we can update it in-place CPython's
26352635
empty tuple is a singleton and cached in PyTuple's freelist. */
2636-
assert(r == 0 || _PyObject_IsUniquelyReferenced(result));
2636+
assert(r == 0 || Py_REFCNT(result) == 1);
26372637

26382638
/* Scan indices right-to-left until finding one that is not
26392639
* at its maximum (n-1). */
@@ -2893,7 +2893,7 @@ permutations_next(PyObject *op)
28932893
_PyTuple_Recycle(result);
28942894
}
28952895
/* Now, we've got the only copy so we can update it in-place */
2896-
assert(r == 0 || _PyObject_IsUniquelyReferenced(result));
2896+
assert(r == 0 || Py_REFCNT(result) == 1);
28972897

28982898
/* Decrement rightmost cycle, moving leftward upon zero rollover */
28992899
for (i=r-1 ; i>=0 ; i--) {

Objects/longobject.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,7 +3848,7 @@ long_add(PyLongObject *a, PyLongObject *b)
38483848
and thus z must be a multiple-digit int.
38493849
That also means z is not an element of
38503850
small_ints, so negating it in-place is safe. */
3851-
assert(_PyObject_IsUniquelyReferenced((PyObject *)z));
3851+
assert(Py_REFCNT(z) == 1);
38523852
_PyLong_FlipSign(z);
38533853
}
38543854
}
@@ -3895,8 +3895,7 @@ long_sub(PyLongObject *a, PyLongObject *b)
38953895
else {
38963896
z = x_add(a, b);
38973897
if (z != NULL) {
3898-
assert(_PyLong_IsZero(z) ||
3899-
_PyObject_IsUniquelyReferenced((PyObject *)z));
3898+
assert(_PyLong_IsZero(z) || Py_REFCNT(z) == 1);
39003899
_PyLong_FlipSign(z);
39013900
}
39023901
}
@@ -5488,7 +5487,7 @@ long_lshift1(PyLongObject *a, Py_ssize_t wordshift, digit remshift)
54885487
if (z == NULL)
54895488
return NULL;
54905489
if (_PyLong_IsNegative(a)) {
5491-
assert(_PyObject_IsUniquelyReferenced((PyObject *)z));
5490+
assert(Py_REFCNT(z) == 1);
54925491
_PyLong_FlipSign(z);
54935492
}
54945493
for (i = 0; i < wordshift; i++)

Objects/setobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ set_update_lock_held(PySetObject *so, PyObject *other)
10581058
static int
10591059
set_update_local(PySetObject *so, PyObject *other)
10601060
{
1061-
assert(_PyObject_IsUniquelyReferenced((PyObject *)so));
1061+
assert(Py_REFCNT(so) == 1);
10621062
if (PyAnySet_Check(other)) {
10631063
int rv;
10641064
Py_BEGIN_CRITICAL_SECTION(other);

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ static int
11621162
resize_inplace(PyObject *unicode, Py_ssize_t length)
11631163
{
11641164
assert(!PyUnicode_IS_COMPACT(unicode));
1165-
assert(_PyObject_IsUniquelyReferenced(unicode));
1165+
assert(Py_REFCNT(unicode) == 1);
11661166

11671167
Py_ssize_t new_size;
11681168
Py_ssize_t char_size;

0 commit comments

Comments
 (0)