mirror of https://github.com/python/cpython
gh-99300: Use Py_NewRef() in Objects/ directory (#99351)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
This commit is contained in:
parent
584e55bd34
commit
1960eb005e
|
@ -62,8 +62,7 @@ get_small_int(sdigit ival)
|
||||||
{
|
{
|
||||||
assert(IS_SMALL_INT(ival));
|
assert(IS_SMALL_INT(ival));
|
||||||
PyObject *v = (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + ival];
|
PyObject *v = (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + ival];
|
||||||
Py_INCREF(v);
|
return Py_NewRef(v);
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyLongObject *
|
static PyLongObject *
|
||||||
|
@ -1785,8 +1784,7 @@ pylong_int_to_decimal_string(PyObject *aa,
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*p_output = (PyObject *)s;
|
*p_output = Py_NewRef(s);
|
||||||
Py_INCREF(s);
|
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2911,8 +2909,7 @@ long_divrem(PyLongObject *a, PyLongObject *b,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PyObject *zero = _PyLong_GetZero();
|
PyObject *zero = _PyLong_GetZero();
|
||||||
Py_INCREF(zero);
|
*pdiv = (PyLongObject*)Py_NewRef(zero);
|
||||||
*pdiv = (PyLongObject*)zero;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (size_b == 1) {
|
if (size_b == 1) {
|
||||||
|
@ -3747,10 +3744,8 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
||||||
assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */
|
assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */
|
||||||
|
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
bh = ah;
|
bh = (PyLongObject*)Py_NewRef(ah);
|
||||||
bl = al;
|
bl = (PyLongObject*)Py_NewRef(al);
|
||||||
Py_INCREF(bh);
|
|
||||||
Py_INCREF(bl);
|
|
||||||
}
|
}
|
||||||
else if (kmul_split(b, shift, &bh, &bl) < 0) goto fail;
|
else if (kmul_split(b, shift, &bh, &bl) < 0) goto fail;
|
||||||
|
|
||||||
|
@ -3822,8 +3817,7 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
||||||
ah = al = NULL;
|
ah = al = NULL;
|
||||||
|
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
t2 = t1;
|
t2 = (PyLongObject*)Py_NewRef(t1);
|
||||||
Py_INCREF(t2);
|
|
||||||
}
|
}
|
||||||
else if ((t2 = x_add(bh, bl)) == NULL) {
|
else if ((t2 = x_add(bh, bl)) == NULL) {
|
||||||
Py_DECREF(t1);
|
Py_DECREF(t1);
|
||||||
|
@ -4067,12 +4061,10 @@ pylong_int_divmod(PyLongObject *v, PyLongObject *w,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (pdiv != NULL) {
|
if (pdiv != NULL) {
|
||||||
Py_INCREF(q);
|
*pdiv = (PyLongObject *)Py_NewRef(q);
|
||||||
*pdiv = (PyLongObject *)q;
|
|
||||||
}
|
}
|
||||||
if (pmod != NULL) {
|
if (pmod != NULL) {
|
||||||
Py_INCREF(r);
|
*pmod = (PyLongObject *)Py_NewRef(r);
|
||||||
*pmod = (PyLongObject *)r;
|
|
||||||
}
|
}
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4638,11 +4630,10 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
||||||
|
|
||||||
/* a, b, c = v, w, x */
|
/* a, b, c = v, w, x */
|
||||||
CHECK_BINOP(v, w);
|
CHECK_BINOP(v, w);
|
||||||
a = (PyLongObject*)v; Py_INCREF(a);
|
a = (PyLongObject*)Py_NewRef(v);
|
||||||
b = (PyLongObject*)w; Py_INCREF(b);
|
b = (PyLongObject*)Py_NewRef(w);
|
||||||
if (PyLong_Check(x)) {
|
if (PyLong_Check(x)) {
|
||||||
c = (PyLongObject *)x;
|
c = (PyLongObject *)Py_NewRef(x);
|
||||||
Py_INCREF(x);
|
|
||||||
}
|
}
|
||||||
else if (x == Py_None)
|
else if (x == Py_None)
|
||||||
c = NULL;
|
c = NULL;
|
||||||
|
@ -4824,8 +4815,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
||||||
/* Left-to-right k-ary sliding window exponentiation
|
/* Left-to-right k-ary sliding window exponentiation
|
||||||
* (Handbook of Applied Cryptography (HAC) Algorithm 14.85)
|
* (Handbook of Applied Cryptography (HAC) Algorithm 14.85)
|
||||||
*/
|
*/
|
||||||
Py_INCREF(a);
|
table[0] = (PyLongObject*)Py_NewRef(a);
|
||||||
table[0] = a;
|
|
||||||
num_table_entries = 1;
|
num_table_entries = 1;
|
||||||
MULT(a, a, a2);
|
MULT(a, a, a2);
|
||||||
/* table[i] == a**(2*i + 1) % c */
|
/* table[i] == a**(2*i + 1) % c */
|
||||||
|
@ -5362,11 +5352,12 @@ long_or(PyObject *a, PyObject *b)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
long_long(PyObject *v)
|
long_long(PyObject *v)
|
||||||
{
|
{
|
||||||
if (PyLong_CheckExact(v))
|
if (PyLong_CheckExact(v)) {
|
||||||
Py_INCREF(v);
|
return Py_NewRef(v);
|
||||||
else
|
}
|
||||||
v = _PyLong_Copy((PyLongObject *)v);
|
else {
|
||||||
return v;
|
return _PyLong_Copy((PyLongObject *)v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
@ -5473,8 +5464,7 @@ _PyLong_GCD(PyObject *aarg, PyObject *barg)
|
||||||
Py_SET_SIZE(c, size_a);
|
Py_SET_SIZE(c, size_a);
|
||||||
}
|
}
|
||||||
else if (Py_REFCNT(a) == 1) {
|
else if (Py_REFCNT(a) == 1) {
|
||||||
Py_INCREF(a);
|
c = (PyLongObject*)Py_NewRef(a);
|
||||||
c = a;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alloc_a = size_a;
|
alloc_a = size_a;
|
||||||
|
@ -5487,8 +5477,7 @@ _PyLong_GCD(PyObject *aarg, PyObject *barg)
|
||||||
Py_SET_SIZE(d, size_a);
|
Py_SET_SIZE(d, size_a);
|
||||||
}
|
}
|
||||||
else if (Py_REFCNT(b) == 1 && size_a <= alloc_b) {
|
else if (Py_REFCNT(b) == 1 && size_a <= alloc_b) {
|
||||||
Py_INCREF(b);
|
d = (PyLongObject*)Py_NewRef(b);
|
||||||
d = b;
|
|
||||||
Py_SET_SIZE(d, size_a);
|
Py_SET_SIZE(d, size_a);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -105,10 +105,8 @@ range_from_array(PyTypeObject *type, PyObject *const *args, Py_ssize_t num_args)
|
||||||
if (!stop) {
|
if (!stop) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
start = _PyLong_GetZero();
|
start = Py_NewRef(_PyLong_GetZero());
|
||||||
Py_INCREF(start);
|
step = Py_NewRef(_PyLong_GetOne());
|
||||||
step = _PyLong_GetOne();
|
|
||||||
Py_INCREF(step);
|
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
@ -216,8 +214,7 @@ compute_range_length(PyObject *start, PyObject *stop, PyObject *step)
|
||||||
if (cmp_result < 0)
|
if (cmp_result < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
result = zero;
|
result = zero;
|
||||||
Py_INCREF(result);
|
return Py_NewRef(result);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tmp1 = PyNumber_Subtract(hi, lo)) == NULL)
|
if ((tmp1 = PyNumber_Subtract(hi, lo)) == NULL)
|
||||||
|
@ -297,8 +294,7 @@ compute_range_item(rangeobject *r, PyObject *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = arg;
|
i = Py_NewRef(arg);
|
||||||
Py_INCREF(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PyLong equivalent to:
|
/* PyLong equivalent to:
|
||||||
|
@ -522,30 +518,24 @@ range_hash(rangeobject *r)
|
||||||
t = PyTuple_New(3);
|
t = PyTuple_New(3);
|
||||||
if (!t)
|
if (!t)
|
||||||
return -1;
|
return -1;
|
||||||
Py_INCREF(r->length);
|
PyTuple_SET_ITEM(t, 0, Py_NewRef(r->length));
|
||||||
PyTuple_SET_ITEM(t, 0, r->length);
|
|
||||||
cmp_result = PyObject_Not(r->length);
|
cmp_result = PyObject_Not(r->length);
|
||||||
if (cmp_result == -1)
|
if (cmp_result == -1)
|
||||||
goto end;
|
goto end;
|
||||||
if (cmp_result == 1) {
|
if (cmp_result == 1) {
|
||||||
Py_INCREF(Py_None);
|
PyTuple_SET_ITEM(t, 1, Py_NewRef(Py_None));
|
||||||
Py_INCREF(Py_None);
|
PyTuple_SET_ITEM(t, 2, Py_NewRef(Py_None));
|
||||||
PyTuple_SET_ITEM(t, 1, Py_None);
|
|
||||||
PyTuple_SET_ITEM(t, 2, Py_None);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Py_INCREF(r->start);
|
PyTuple_SET_ITEM(t, 1, Py_NewRef(r->start));
|
||||||
PyTuple_SET_ITEM(t, 1, r->start);
|
|
||||||
cmp_result = PyObject_RichCompareBool(r->length, _PyLong_GetOne(), Py_EQ);
|
cmp_result = PyObject_RichCompareBool(r->length, _PyLong_GetOne(), Py_EQ);
|
||||||
if (cmp_result == -1)
|
if (cmp_result == -1)
|
||||||
goto end;
|
goto end;
|
||||||
if (cmp_result == 1) {
|
if (cmp_result == 1) {
|
||||||
Py_INCREF(Py_None);
|
PyTuple_SET_ITEM(t, 2, Py_NewRef(Py_None));
|
||||||
PyTuple_SET_ITEM(t, 2, Py_None);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Py_INCREF(r->step);
|
PyTuple_SET_ITEM(t, 2, Py_NewRef(r->step));
|
||||||
PyTuple_SET_ITEM(t, 2, r->step);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = PyObject_Hash(t);
|
result = PyObject_Hash(t);
|
||||||
|
@ -982,8 +972,7 @@ longrangeiter_setstate(longrangeiterobject *r, PyObject *state)
|
||||||
if (cmp > 0)
|
if (cmp > 0)
|
||||||
state = r->len;
|
state = r->len;
|
||||||
}
|
}
|
||||||
Py_INCREF(state);
|
Py_XSETREF(r->index, Py_NewRef(state));
|
||||||
Py_XSETREF(r->index, state);
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,14 +1107,10 @@ range_iter(PyObject *seq)
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
it->start = r->start;
|
it->start = Py_NewRef(r->start);
|
||||||
it->step = r->step;
|
it->step = Py_NewRef(r->step);
|
||||||
it->len = r->length;
|
it->len = Py_NewRef(r->length);
|
||||||
it->index = _PyLong_GetZero();
|
it->index = Py_NewRef(_PyLong_GetZero());
|
||||||
Py_INCREF(it->start);
|
|
||||||
Py_INCREF(it->step);
|
|
||||||
Py_INCREF(it->len);
|
|
||||||
Py_INCREF(it->index);
|
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,8 +1191,7 @@ long_range:
|
||||||
it->index = it->start = it->step = NULL;
|
it->index = it->start = it->step = NULL;
|
||||||
|
|
||||||
/* start + (len - 1) * step */
|
/* start + (len - 1) * step */
|
||||||
it->len = range->length;
|
it->len = Py_NewRef(range->length);
|
||||||
Py_INCREF(it->len);
|
|
||||||
|
|
||||||
diff = PyNumber_Subtract(it->len, _PyLong_GetOne());
|
diff = PyNumber_Subtract(it->len, _PyLong_GetOne());
|
||||||
if (!diff)
|
if (!diff)
|
||||||
|
@ -1228,8 +1212,7 @@ long_range:
|
||||||
if (!it->step)
|
if (!it->step)
|
||||||
goto create_failure;
|
goto create_failure;
|
||||||
|
|
||||||
it->index = _PyLong_GetZero();
|
it->index = Py_NewRef(_PyLong_GetZero());
|
||||||
Py_INCREF(it->index);
|
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
|
|
||||||
create_failure:
|
create_failure:
|
||||||
|
|
|
@ -61,8 +61,7 @@ tuple_alloc(Py_ssize_t size)
|
||||||
static inline PyObject *
|
static inline PyObject *
|
||||||
tuple_get_empty(void)
|
tuple_get_empty(void)
|
||||||
{
|
{
|
||||||
Py_INCREF(&_Py_SINGLETON(tuple_empty));
|
return Py_NewRef(&_Py_SINGLETON(tuple_empty));
|
||||||
return (PyObject *)&_Py_SINGLETON(tuple_empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
@ -171,8 +170,7 @@ PyTuple_Pack(Py_ssize_t n, ...)
|
||||||
items = result->ob_item;
|
items = result->ob_item;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
o = va_arg(vargs, PyObject *);
|
o = va_arg(vargs, PyObject *);
|
||||||
Py_INCREF(o);
|
items[i] = Py_NewRef(o);
|
||||||
items[i] = o;
|
|
||||||
}
|
}
|
||||||
va_end(vargs);
|
va_end(vargs);
|
||||||
_PyObject_GC_TRACK(result);
|
_PyObject_GC_TRACK(result);
|
||||||
|
@ -367,8 +365,7 @@ tupleitem(PyTupleObject *a, Py_ssize_t i)
|
||||||
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
|
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(a->ob_item[i]);
|
return Py_NewRef(a->ob_item[i]);
|
||||||
return a->ob_item[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
@ -385,8 +382,7 @@ _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
|
||||||
PyObject **dst = tuple->ob_item;
|
PyObject **dst = tuple->ob_item;
|
||||||
for (Py_ssize_t i = 0; i < n; i++) {
|
for (Py_ssize_t i = 0; i < n; i++) {
|
||||||
PyObject *item = src[i];
|
PyObject *item = src[i];
|
||||||
Py_INCREF(item);
|
dst[i] = Py_NewRef(item);
|
||||||
dst[i] = item;
|
|
||||||
}
|
}
|
||||||
_PyObject_GC_TRACK(tuple);
|
_PyObject_GC_TRACK(tuple);
|
||||||
return (PyObject *)tuple;
|
return (PyObject *)tuple;
|
||||||
|
@ -425,8 +421,7 @@ tupleslice(PyTupleObject *a, Py_ssize_t ilow,
|
||||||
if (ihigh < ilow)
|
if (ihigh < ilow)
|
||||||
ihigh = ilow;
|
ihigh = ilow;
|
||||||
if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
|
if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
|
||||||
Py_INCREF(a);
|
return Py_NewRef(a);
|
||||||
return (PyObject *)a;
|
|
||||||
}
|
}
|
||||||
return _PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
|
return _PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
|
||||||
}
|
}
|
||||||
|
@ -449,8 +444,7 @@ tupleconcat(PyTupleObject *a, PyObject *bb)
|
||||||
PyObject **src, **dest;
|
PyObject **src, **dest;
|
||||||
PyTupleObject *np;
|
PyTupleObject *np;
|
||||||
if (Py_SIZE(a) == 0 && PyTuple_CheckExact(bb)) {
|
if (Py_SIZE(a) == 0 && PyTuple_CheckExact(bb)) {
|
||||||
Py_INCREF(bb);
|
return Py_NewRef(bb);
|
||||||
return bb;
|
|
||||||
}
|
}
|
||||||
if (!PyTuple_Check(bb)) {
|
if (!PyTuple_Check(bb)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
@ -461,8 +455,7 @@ tupleconcat(PyTupleObject *a, PyObject *bb)
|
||||||
PyTupleObject *b = (PyTupleObject *)bb;
|
PyTupleObject *b = (PyTupleObject *)bb;
|
||||||
|
|
||||||
if (Py_SIZE(b) == 0 && PyTuple_CheckExact(a)) {
|
if (Py_SIZE(b) == 0 && PyTuple_CheckExact(a)) {
|
||||||
Py_INCREF(a);
|
return Py_NewRef(a);
|
||||||
return (PyObject *)a;
|
|
||||||
}
|
}
|
||||||
assert((size_t)Py_SIZE(a) + (size_t)Py_SIZE(b) < PY_SSIZE_T_MAX);
|
assert((size_t)Py_SIZE(a) + (size_t)Py_SIZE(b) < PY_SSIZE_T_MAX);
|
||||||
size = Py_SIZE(a) + Py_SIZE(b);
|
size = Py_SIZE(a) + Py_SIZE(b);
|
||||||
|
@ -478,15 +471,13 @@ tupleconcat(PyTupleObject *a, PyObject *bb)
|
||||||
dest = np->ob_item;
|
dest = np->ob_item;
|
||||||
for (i = 0; i < Py_SIZE(a); i++) {
|
for (i = 0; i < Py_SIZE(a); i++) {
|
||||||
PyObject *v = src[i];
|
PyObject *v = src[i];
|
||||||
Py_INCREF(v);
|
dest[i] = Py_NewRef(v);
|
||||||
dest[i] = v;
|
|
||||||
}
|
}
|
||||||
src = b->ob_item;
|
src = b->ob_item;
|
||||||
dest = np->ob_item + Py_SIZE(a);
|
dest = np->ob_item + Py_SIZE(a);
|
||||||
for (i = 0; i < Py_SIZE(b); i++) {
|
for (i = 0; i < Py_SIZE(b); i++) {
|
||||||
PyObject *v = src[i];
|
PyObject *v = src[i];
|
||||||
Py_INCREF(v);
|
dest[i] = Py_NewRef(v);
|
||||||
dest[i] = v;
|
|
||||||
}
|
}
|
||||||
_PyObject_GC_TRACK(np);
|
_PyObject_GC_TRACK(np);
|
||||||
return (PyObject *)np;
|
return (PyObject *)np;
|
||||||
|
@ -500,8 +491,7 @@ tuplerepeat(PyTupleObject *a, Py_ssize_t n)
|
||||||
if (PyTuple_CheckExact(a)) {
|
if (PyTuple_CheckExact(a)) {
|
||||||
/* Since tuples are immutable, we can return a shared
|
/* Since tuples are immutable, we can return a shared
|
||||||
copy in this case */
|
copy in this case */
|
||||||
Py_INCREF(a);
|
return Py_NewRef(a);
|
||||||
return (PyObject *)a;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input_size == 0 || n <= 0) {
|
if (input_size == 0 || n <= 0) {
|
||||||
|
@ -747,8 +737,7 @@ tuple_subtype_new(PyTypeObject *type, PyObject *iterable)
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
item = PyTuple_GET_ITEM(tmp, i);
|
item = PyTuple_GET_ITEM(tmp, i);
|
||||||
Py_INCREF(item);
|
PyTuple_SET_ITEM(newobj, i, Py_NewRef(item));
|
||||||
PyTuple_SET_ITEM(newobj, i, item);
|
|
||||||
}
|
}
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
|
|
||||||
|
@ -799,8 +788,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
|
||||||
else if (start == 0 && step == 1 &&
|
else if (start == 0 && step == 1 &&
|
||||||
slicelength == PyTuple_GET_SIZE(self) &&
|
slicelength == PyTuple_GET_SIZE(self) &&
|
||||||
PyTuple_CheckExact(self)) {
|
PyTuple_CheckExact(self)) {
|
||||||
Py_INCREF(self);
|
return Py_NewRef(self);
|
||||||
return (PyObject *)self;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyTupleObject* result = tuple_alloc(slicelength);
|
PyTupleObject* result = tuple_alloc(slicelength);
|
||||||
|
@ -810,8 +798,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
|
||||||
dest = result->ob_item;
|
dest = result->ob_item;
|
||||||
for (cur = start, i = 0; i < slicelength;
|
for (cur = start, i = 0; i < slicelength;
|
||||||
cur += step, i++) {
|
cur += step, i++) {
|
||||||
it = src[cur];
|
it = Py_NewRef(src[cur]);
|
||||||
Py_INCREF(it);
|
|
||||||
dest[i] = it;
|
dest[i] = it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1044,8 +1031,7 @@ tupleiter_next(tupleiterobject *it)
|
||||||
if (it->it_index < PyTuple_GET_SIZE(seq)) {
|
if (it->it_index < PyTuple_GET_SIZE(seq)) {
|
||||||
item = PyTuple_GET_ITEM(seq, it->it_index);
|
item = PyTuple_GET_ITEM(seq, it->it_index);
|
||||||
++it->it_index;
|
++it->it_index;
|
||||||
Py_INCREF(item);
|
return Py_NewRef(item);
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it->it_seq = NULL;
|
it->it_seq = NULL;
|
||||||
|
@ -1146,8 +1132,7 @@ tuple_iter(PyObject *seq)
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
it->it_index = 0;
|
it->it_index = 0;
|
||||||
Py_INCREF(seq);
|
it->it_seq = (PyTupleObject *)Py_NewRef(seq);
|
||||||
it->it_seq = (PyTupleObject *)seq;
|
|
||||||
_PyObject_GC_TRACK(it);
|
_PyObject_GC_TRACK(it);
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,8 +653,7 @@ type_name(PyTypeObject *type, void *context)
|
||||||
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
|
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
|
||||||
PyHeapTypeObject* et = (PyHeapTypeObject*)type;
|
PyHeapTypeObject* et = (PyHeapTypeObject*)type;
|
||||||
|
|
||||||
Py_INCREF(et->ht_name);
|
return Py_NewRef(et->ht_name);
|
||||||
return et->ht_name;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return PyUnicode_FromString(_PyType_Name(type));
|
return PyUnicode_FromString(_PyType_Name(type));
|
||||||
|
@ -666,8 +665,7 @@ type_qualname(PyTypeObject *type, void *context)
|
||||||
{
|
{
|
||||||
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
|
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
|
||||||
PyHeapTypeObject* et = (PyHeapTypeObject*)type;
|
PyHeapTypeObject* et = (PyHeapTypeObject*)type;
|
||||||
Py_INCREF(et->ht_qualname);
|
return Py_NewRef(et->ht_qualname);
|
||||||
return et->ht_qualname;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return PyUnicode_FromString(_PyType_Name(type));
|
return PyUnicode_FromString(_PyType_Name(type));
|
||||||
|
@ -699,8 +697,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
|
||||||
}
|
}
|
||||||
|
|
||||||
type->tp_name = tp_name;
|
type->tp_name = tp_name;
|
||||||
Py_INCREF(value);
|
Py_SETREF(((PyHeapTypeObject*)type)->ht_name, Py_NewRef(value));
|
||||||
Py_SETREF(((PyHeapTypeObject*)type)->ht_name, value);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -720,8 +717,7 @@ type_set_qualname(PyTypeObject *type, PyObject *value, void *context)
|
||||||
}
|
}
|
||||||
|
|
||||||
et = (PyHeapTypeObject*)type;
|
et = (PyHeapTypeObject*)type;
|
||||||
Py_INCREF(value);
|
Py_SETREF(et->ht_qualname, Py_NewRef(value));
|
||||||
Py_SETREF(et->ht_qualname, value);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,8 +745,7 @@ type_module(PyTypeObject *type, void *context)
|
||||||
PyUnicode_InternInPlace(&mod);
|
PyUnicode_InternInPlace(&mod);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mod = &_Py_ID(builtins);
|
mod = Py_NewRef(&_Py_ID(builtins));
|
||||||
Py_INCREF(mod);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mod;
|
return mod;
|
||||||
|
@ -782,8 +777,7 @@ type_abstractmethods(PyTypeObject *type, void *context)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(mod);
|
return Py_NewRef(mod);
|
||||||
return mod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -821,8 +815,7 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
type_get_bases(PyTypeObject *type, void *context)
|
type_get_bases(PyTypeObject *type, void *context)
|
||||||
{
|
{
|
||||||
Py_INCREF(type->tp_bases);
|
return Py_NewRef(type->tp_bases);
|
||||||
return type->tp_bases;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject *best_base(PyObject *);
|
static PyTypeObject *best_base(PyObject *);
|
||||||
|
@ -1016,8 +1009,7 @@ type_set_bases(PyTypeObject *type, PyObject *new_bases, void *context)
|
||||||
"", 2, 3, &cls, &new_mro, &old_mro);
|
"", 2, 3, &cls, &new_mro, &old_mro);
|
||||||
/* Do not rollback if cls has a newer version of MRO. */
|
/* Do not rollback if cls has a newer version of MRO. */
|
||||||
if (cls->tp_mro == new_mro) {
|
if (cls->tp_mro == new_mro) {
|
||||||
Py_XINCREF(old_mro);
|
cls->tp_mro = Py_XNewRef(old_mro);
|
||||||
cls->tp_mro = old_mro;
|
|
||||||
Py_DECREF(new_mro);
|
Py_DECREF(new_mro);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1061,8 +1053,7 @@ type_get_doc(PyTypeObject *type, void *context)
|
||||||
result = PyDict_GetItemWithError(type->tp_dict, &_Py_ID(__doc__));
|
result = PyDict_GetItemWithError(type->tp_dict, &_Py_ID(__doc__));
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
result = Py_None;
|
result = Py_NewRef(Py_None);
|
||||||
Py_INCREF(result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Py_TYPE(result)->tp_descr_get) {
|
else if (Py_TYPE(result)->tp_descr_get) {
|
||||||
|
@ -1264,8 +1255,7 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
if (nargs == 1 && (kwds == NULL || !PyDict_GET_SIZE(kwds))) {
|
if (nargs == 1 && (kwds == NULL || !PyDict_GET_SIZE(kwds))) {
|
||||||
obj = (PyObject *) Py_TYPE(PyTuple_GET_ITEM(args, 0));
|
obj = (PyObject *) Py_TYPE(PyTuple_GET_ITEM(args, 0));
|
||||||
Py_INCREF(obj);
|
return Py_NewRef(obj);
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SF bug 475327 -- if that didn't trigger, we need 3
|
/* SF bug 475327 -- if that didn't trigger, we need 3
|
||||||
|
@ -2144,12 +2134,11 @@ mro_implementation(PyTypeObject *type)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(type);
|
;
|
||||||
PyTuple_SET_ITEM(result, 0, (PyObject *) type);
|
PyTuple_SET_ITEM(result, 0, Py_NewRef(type));
|
||||||
for (Py_ssize_t i = 0; i < k; i++) {
|
for (Py_ssize_t i = 0; i < k; i++) {
|
||||||
PyObject *cls = PyTuple_GET_ITEM(base->tp_mro, i);
|
PyObject *cls = PyTuple_GET_ITEM(base->tp_mro, i);
|
||||||
Py_INCREF(cls);
|
PyTuple_SET_ITEM(result, i + 1, Py_NewRef(cls));
|
||||||
PyTuple_SET_ITEM(result, i + 1, cls);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2185,8 +2174,7 @@ mro_implementation(PyTypeObject *type)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(type);
|
PyList_SET_ITEM(result, 0, Py_NewRef(type));
|
||||||
PyList_SET_ITEM(result, 0, (PyObject *)type);
|
|
||||||
if (pmerge(result, to_merge, n + 1) < 0) {
|
if (pmerge(result, to_merge, n + 1) < 0) {
|
||||||
Py_CLEAR(result);
|
Py_CLEAR(result);
|
||||||
}
|
}
|
||||||
|
@ -2331,8 +2319,7 @@ mro_internal(PyTypeObject *type, PyObject **p_old_mro)
|
||||||
/* Keep a reference to be able to do a reentrancy check below.
|
/* Keep a reference to be able to do a reentrancy check below.
|
||||||
Don't let old_mro be GC'ed and its address be reused for
|
Don't let old_mro be GC'ed and its address be reused for
|
||||||
another object, like (suddenly!) a new tp_mro. */
|
another object, like (suddenly!) a new tp_mro. */
|
||||||
old_mro = type->tp_mro;
|
old_mro = Py_XNewRef(type->tp_mro);
|
||||||
Py_XINCREF(old_mro);
|
|
||||||
new_mro = mro_invoke(type); /* might cause reentrance */
|
new_mro = mro_invoke(type); /* might cause reentrance */
|
||||||
reent = (type->tp_mro != old_mro);
|
reent = (type->tp_mro != old_mro);
|
||||||
Py_XDECREF(old_mro);
|
Py_XDECREF(old_mro);
|
||||||
|
@ -2550,8 +2537,7 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context)
|
||||||
"not a '%.200s'", Py_TYPE(value)->tp_name);
|
"not a '%.200s'", Py_TYPE(value)->tp_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_XINCREF(value);
|
Py_XSETREF(*dictptr, Py_XNewRef(value));
|
||||||
Py_XSETREF(*dictptr, value);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2578,8 +2564,7 @@ subtype_getweakref(PyObject *obj, void *context)
|
||||||
result = Py_None;
|
result = Py_None;
|
||||||
else
|
else
|
||||||
result = *weaklistptr;
|
result = *weaklistptr;
|
||||||
Py_INCREF(result);
|
return Py_NewRef(result);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Three variants on the subtype_getsets list. */
|
/* Three variants on the subtype_getsets list. */
|
||||||
|
@ -5063,16 +5048,14 @@ object_richcompare(PyObject *self, PyObject *other, int op)
|
||||||
/* Return NotImplemented instead of False, so if two
|
/* Return NotImplemented instead of False, so if two
|
||||||
objects are compared, both get a chance at the
|
objects are compared, both get a chance at the
|
||||||
comparison. See issue #1393. */
|
comparison. See issue #1393. */
|
||||||
res = (self == other) ? Py_True : Py_NotImplemented;
|
res = Py_NewRef((self == other) ? Py_True : Py_NotImplemented);
|
||||||
Py_INCREF(res);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Py_NE:
|
case Py_NE:
|
||||||
/* By default, __ne__() delegates to __eq__() and inverts the result,
|
/* By default, __ne__() delegates to __eq__() and inverts the result,
|
||||||
unless the latter returns NotImplemented. */
|
unless the latter returns NotImplemented. */
|
||||||
if (Py_TYPE(self)->tp_richcompare == NULL) {
|
if (Py_TYPE(self)->tp_richcompare == NULL) {
|
||||||
res = Py_NotImplemented;
|
res = Py_NewRef(Py_NotImplemented);
|
||||||
Py_INCREF(res);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res = (*Py_TYPE(self)->tp_richcompare)(self, other, Py_EQ);
|
res = (*Py_TYPE(self)->tp_richcompare)(self, other, Py_EQ);
|
||||||
|
@ -5083,17 +5066,15 @@ object_richcompare(PyObject *self, PyObject *other, int op)
|
||||||
res = NULL;
|
res = NULL;
|
||||||
else {
|
else {
|
||||||
if (ok)
|
if (ok)
|
||||||
res = Py_False;
|
res = Py_NewRef(Py_False);
|
||||||
else
|
else
|
||||||
res = Py_True;
|
res = Py_NewRef(Py_True);
|
||||||
Py_INCREF(res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
res = Py_NotImplemented;
|
res = Py_NewRef(Py_NotImplemented);
|
||||||
Py_INCREF(res);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5103,8 +5084,7 @@ object_richcompare(PyObject *self, PyObject *other, int op)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
object_get_class(PyObject *self, void *closure)
|
object_get_class(PyObject *self, void *closure)
|
||||||
{
|
{
|
||||||
Py_INCREF(Py_TYPE(self));
|
return Py_NewRef(Py_TYPE(self));
|
||||||
return (PyObject *)(Py_TYPE(self));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -5359,8 +5339,7 @@ _PyType_GetSlotNames(PyTypeObject *cls)
|
||||||
cls->tp_name, Py_TYPE(slotnames)->tp_name);
|
cls->tp_name, Py_TYPE(slotnames)->tp_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(slotnames);
|
return Py_NewRef(slotnames);
|
||||||
return slotnames;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
|
@ -5406,8 +5385,7 @@ object_getstate_default(PyObject *obj, int required)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_PyObject_IsInstanceDictEmpty(obj)) {
|
if (_PyObject_IsInstanceDictEmpty(obj)) {
|
||||||
state = Py_None;
|
state = Py_NewRef(Py_None);
|
||||||
Py_INCREF(state);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state = PyObject_GenericGetDict(obj, NULL);
|
state = PyObject_GenericGetDict(obj, NULL);
|
||||||
|
@ -5665,8 +5643,7 @@ _PyObject_GetItemsIter(PyObject *obj, PyObject **listitems,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PyList_Check(obj)) {
|
if (!PyList_Check(obj)) {
|
||||||
*listitems = Py_None;
|
*listitems = Py_NewRef(Py_None);
|
||||||
Py_INCREF(*listitems);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*listitems = PyObject_GetIter(obj);
|
*listitems = PyObject_GetIter(obj);
|
||||||
|
@ -5675,8 +5652,7 @@ _PyObject_GetItemsIter(PyObject *obj, PyObject **listitems,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PyDict_Check(obj)) {
|
if (!PyDict_Check(obj)) {
|
||||||
*dictitems = Py_None;
|
*dictitems = Py_NewRef(Py_None);
|
||||||
Py_INCREF(*dictitems);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyObject *items = PyObject_CallMethodNoArgs(obj, &_Py_ID(items));
|
PyObject *items = PyObject_CallMethodNoArgs(obj, &_Py_ID(items));
|
||||||
|
@ -5741,12 +5717,10 @@ reduce_newobj(PyObject *obj)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cls = (PyObject *) Py_TYPE(obj);
|
cls = (PyObject *) Py_TYPE(obj);
|
||||||
Py_INCREF(cls);
|
PyTuple_SET_ITEM(newargs, 0, Py_NewRef(cls));
|
||||||
PyTuple_SET_ITEM(newargs, 0, cls);
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
PyObject *v = PyTuple_GET_ITEM(args, i);
|
PyObject *v = PyTuple_GET_ITEM(args, i);
|
||||||
Py_INCREF(v);
|
PyTuple_SET_ITEM(newargs, i+1, Py_NewRef(v));
|
||||||
PyTuple_SET_ITEM(newargs, i+1, v);
|
|
||||||
}
|
}
|
||||||
Py_XDECREF(args);
|
Py_XDECREF(args);
|
||||||
}
|
}
|
||||||
|
@ -8381,8 +8355,7 @@ slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
/* Avoid further slowdowns */
|
/* Avoid further slowdowns */
|
||||||
if (tp->tp_descr_get == slot_tp_descr_get)
|
if (tp->tp_descr_get == slot_tp_descr_get)
|
||||||
tp->tp_descr_get = NULL;
|
tp->tp_descr_get = NULL;
|
||||||
Py_INCREF(self);
|
return Py_NewRef(self);
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
obj = Py_None;
|
obj = Py_None;
|
||||||
|
@ -9451,14 +9424,12 @@ supercheck(PyTypeObject *type, PyObject *obj)
|
||||||
|
|
||||||
/* Check for first bullet above (special case) */
|
/* Check for first bullet above (special case) */
|
||||||
if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) {
|
if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) {
|
||||||
Py_INCREF(obj);
|
return (PyTypeObject *)Py_NewRef(obj);
|
||||||
return (PyTypeObject *)obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normal case */
|
/* Normal case */
|
||||||
if (PyType_IsSubtype(Py_TYPE(obj), type)) {
|
if (PyType_IsSubtype(Py_TYPE(obj), type)) {
|
||||||
Py_INCREF(Py_TYPE(obj));
|
return (PyTypeObject*)Py_NewRef(Py_TYPE(obj));
|
||||||
return Py_TYPE(obj);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Try the slow way */
|
/* Try the slow way */
|
||||||
|
@ -9494,8 +9465,7 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
|
|
||||||
if (obj == NULL || obj == Py_None || su->obj != NULL) {
|
if (obj == NULL || obj == Py_None || su->obj != NULL) {
|
||||||
/* Not binding to an object, or already bound */
|
/* Not binding to an object, or already bound */
|
||||||
Py_INCREF(self);
|
return Py_NewRef(self);
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
if (!Py_IS_TYPE(su, &PySuper_Type))
|
if (!Py_IS_TYPE(su, &PySuper_Type))
|
||||||
/* If su is an instance of a (strict) subclass of super,
|
/* If su is an instance of a (strict) subclass of super,
|
||||||
|
@ -9511,10 +9481,8 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (newobj == NULL)
|
if (newobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_INCREF(su->type);
|
newobj->type = (PyTypeObject*)Py_NewRef(su->type);
|
||||||
Py_INCREF(obj);
|
newobj->obj = Py_NewRef(obj);
|
||||||
newobj->type = su->type;
|
|
||||||
newobj->obj = obj;
|
|
||||||
newobj->obj_type = obj_type;
|
newobj->obj_type = obj_type;
|
||||||
return (PyObject *)newobj;
|
return (PyObject *)newobj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,8 +221,7 @@ static inline PyObject* unicode_get_empty(void)
|
||||||
static inline PyObject* unicode_new_empty(void)
|
static inline PyObject* unicode_new_empty(void)
|
||||||
{
|
{
|
||||||
PyObject *empty = unicode_get_empty();
|
PyObject *empty = unicode_get_empty();
|
||||||
Py_INCREF(empty);
|
return Py_NewRef(empty);
|
||||||
return empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This dictionary holds all interned unicode strings. Note that references
|
/* This dictionary holds all interned unicode strings. Note that references
|
||||||
|
@ -611,8 +610,7 @@ static PyObject*
|
||||||
unicode_result_unchanged(PyObject *unicode)
|
unicode_result_unchanged(PyObject *unicode)
|
||||||
{
|
{
|
||||||
if (PyUnicode_CheckExact(unicode)) {
|
if (PyUnicode_CheckExact(unicode)) {
|
||||||
Py_INCREF(unicode);
|
return Py_NewRef(unicode);
|
||||||
return unicode;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Subtype -- return genuine unicode string with the same value. */
|
/* Subtype -- return genuine unicode string with the same value. */
|
||||||
|
@ -2947,8 +2945,7 @@ PyUnicode_FromObject(PyObject *obj)
|
||||||
/* XXX Perhaps we should make this API an alias of
|
/* XXX Perhaps we should make this API an alias of
|
||||||
PyObject_Str() instead ?! */
|
PyObject_Str() instead ?! */
|
||||||
if (PyUnicode_CheckExact(obj)) {
|
if (PyUnicode_CheckExact(obj)) {
|
||||||
Py_INCREF(obj);
|
return Py_NewRef(obj);
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
if (PyUnicode_Check(obj)) {
|
if (PyUnicode_Check(obj)) {
|
||||||
/* For a Unicode subtype that's not a Unicode object,
|
/* For a Unicode subtype that's not a Unicode object,
|
||||||
|
@ -8668,8 +8665,7 @@ _PyUnicode_TransformDecimalAndSpaceToASCII(PyObject *unicode)
|
||||||
}
|
}
|
||||||
if (PyUnicode_IS_ASCII(unicode)) {
|
if (PyUnicode_IS_ASCII(unicode)) {
|
||||||
/* If the string is already ASCII, just return the same string */
|
/* If the string is already ASCII, just return the same string */
|
||||||
Py_INCREF(unicode);
|
return Py_NewRef(unicode);
|
||||||
return unicode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_ssize_t len = PyUnicode_GET_LENGTH(unicode);
|
Py_ssize_t len = PyUnicode_GET_LENGTH(unicode);
|
||||||
|
@ -9413,8 +9409,7 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject *const *items, Py_ssize_t seq
|
||||||
if (seqlen == 1) {
|
if (seqlen == 1) {
|
||||||
if (PyUnicode_CheckExact(items[0])) {
|
if (PyUnicode_CheckExact(items[0])) {
|
||||||
res = items[0];
|
res = items[0];
|
||||||
Py_INCREF(res);
|
return Py_NewRef(res);
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
seplen = 0;
|
seplen = 0;
|
||||||
maxchar = 0;
|
maxchar = 0;
|
||||||
|
@ -9733,8 +9728,7 @@ split(PyObject *self,
|
||||||
out = PyList_New(1);
|
out = PyList_New(1);
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_INCREF(self);
|
PyList_SET_ITEM(out, 0, Py_NewRef(self));
|
||||||
PyList_SET_ITEM(out, 0, self);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
buf1 = PyUnicode_DATA(self);
|
buf1 = PyUnicode_DATA(self);
|
||||||
|
@ -9826,8 +9820,7 @@ rsplit(PyObject *self,
|
||||||
out = PyList_New(1);
|
out = PyList_New(1);
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_INCREF(self);
|
PyList_SET_ITEM(out, 0, Py_NewRef(self));
|
||||||
PyList_SET_ITEM(out, 0, self);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
buf1 = PyUnicode_DATA(self);
|
buf1 = PyUnicode_DATA(self);
|
||||||
|
@ -10746,8 +10739,7 @@ PyUnicode_Append(PyObject **p_left, PyObject *right)
|
||||||
PyObject *empty = unicode_get_empty(); // Borrowed reference
|
PyObject *empty = unicode_get_empty(); // Borrowed reference
|
||||||
if (left == empty) {
|
if (left == empty) {
|
||||||
Py_DECREF(left);
|
Py_DECREF(left);
|
||||||
Py_INCREF(right);
|
*p_left = Py_NewRef(right);
|
||||||
*p_left = right;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (right == empty) {
|
if (right == empty) {
|
||||||
|
@ -12977,8 +12969,7 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str)
|
||||||
if (writer->buffer == NULL && !writer->overallocate) {
|
if (writer->buffer == NULL && !writer->overallocate) {
|
||||||
assert(_PyUnicode_CheckConsistency(str, 1));
|
assert(_PyUnicode_CheckConsistency(str, 1));
|
||||||
writer->readonly = 1;
|
writer->readonly = 1;
|
||||||
Py_INCREF(str);
|
writer->buffer = Py_NewRef(str);
|
||||||
writer->buffer = str;
|
|
||||||
_PyUnicodeWriter_Update(writer);
|
_PyUnicodeWriter_Update(writer);
|
||||||
writer->pos += len;
|
writer->pos += len;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -13641,8 +13632,7 @@ mainformatlong(PyObject *v,
|
||||||
assert(PyLong_Check(iobj));
|
assert(PyLong_Check(iobj));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
iobj = v;
|
iobj = Py_NewRef(v);
|
||||||
Py_INCREF(iobj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyLong_CheckExact(v)
|
if (PyLong_CheckExact(v)
|
||||||
|
@ -13965,8 +13955,7 @@ unicode_format_arg_format(struct unicode_formatter_t *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyUnicode_CheckExact(v) && arg->ch == 's') {
|
if (PyUnicode_CheckExact(v) && arg->ch == 's') {
|
||||||
*p_str = v;
|
*p_str = Py_NewRef(v);
|
||||||
Py_INCREF(*p_str);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (arg->ch == 's')
|
if (arg->ch == 's')
|
||||||
|
@ -14616,8 +14605,7 @@ PyUnicode_InternInPlace(PyObject **p)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t != s) {
|
if (t != s) {
|
||||||
Py_INCREF(t);
|
Py_SETREF(*p, Py_NewRef(t));
|
||||||
Py_SETREF(*p, t);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14887,8 +14875,7 @@ unicode_iter(PyObject *seq)
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
it->it_index = 0;
|
it->it_index = 0;
|
||||||
Py_INCREF(seq);
|
it->it_seq = Py_NewRef(seq);
|
||||||
it->it_seq = seq;
|
|
||||||
_PyObject_GC_TRACK(it);
|
_PyObject_GC_TRACK(it);
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue