Skip to content

Commit 55a441b

Browse files
committed
Adjust code for 3.14
1 parent d283adf commit 55a441b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎Objects/bytesobject.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,9 +3217,7 @@ int
32173217
_PyBytes_IsMutable(PyObject *self)
32183218
{
32193219
assert(PyBytes_Check(self));
3220-
// Do not use _PyObject_IsUniquelyReferenced(): this function is called
3221-
// by bytearray and PyBytesWriter which can be used by multiple threads.
3222-
assert(Py_REFCNT(self) == 1);
3220+
assert(_PyObject_IsUniquelyReferenced(self));
32233221
assert(!_Py_IsImmortal(self));
32243222

32253223
// Check that the object is not a singleton
@@ -3240,9 +3238,7 @@ static inline int
32403238
bytes_resize_inplace(PyObject **pv, Py_ssize_t newsize)
32413239
{
32423240
PyObject *v = *pv;
3243-
// Do not test _PyObject_IsUniquelyReferenced(). The function is used by
3244-
// PyBytesWriter_FinishWithSize() and its caller can have its own lock.
3245-
assert(Py_REFCNT(v) == 1);
3241+
assert(_PyObject_IsUniquelyReferenced(v));
32463242
assert(PyBytes_GET_SIZE(v) >= 1);
32473243
assert(newsize >= 1);
32483244

@@ -3321,6 +3317,7 @@ _PyBytes_ResizeKeepOnError(PyObject **pv, Py_ssize_t newsize)
33213317
}
33223318
*pv = result;
33233319
Py_DECREF(v);
3320+
assert(_PyBytes_IsMutable(*pv));
33243321
return 0;
33253322
}
33263323

@@ -3345,6 +3342,7 @@ _PyBytes_ResizeKeepOnError(PyObject **pv, Py_ssize_t newsize)
33453342
Py_MIN(oldsize, newsize));
33463343
*pv = result;
33473344
Py_DECREF(v);
3345+
assert(_PyBytes_IsMutable(*pv));
33483346
return 0;
33493347
}
33503348

0 commit comments

Comments
 (0)