Skip to content

Commit 850e2fc

Browse files
using xdecref is not semantically consistent yet
1 parent 7a869ed commit 850e2fc

File tree

7 files changed

+51
-51
lines changed

7 files changed

+51
-51
lines changed

src/JSArrayProxy.cc

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_richcompare(JSArrayProxy *
471471
continue;
472472
}
473473

474-
Py_XINCREF(leftItem);
474+
Py_INCREF(leftItem);
475475
Py_INCREF(rightItem);
476476
int k = PyObject_RichCompareBool(leftItem, rightItem, Py_EQ);
477-
Py_XDECREF(leftItem);
477+
Py_DECREF(leftItem);
478478
Py_DECREF(rightItem);
479479
if (k < 0) {
480480
return NULL;
@@ -483,7 +483,7 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_richcompare(JSArrayProxy *
483483
break;
484484
}
485485

486-
Py_XDECREF(leftItem);
486+
Py_DECREF(leftItem);
487487
if (needToDecRefRightItem) {
488488
Py_DECREF(rightItem);
489489
}
@@ -506,7 +506,7 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_richcompare(JSArrayProxy *
506506
/* Compare the final item again using the proper operator */
507507
PyObject *pyElementVal = pyTypeFactory(GLOBAL_CX, elementVal);
508508
PyObject *result = PyObject_RichCompare(pyElementVal, ((PyListObject *)other)->ob_item[index], op);
509-
Py_XDECREF(pyElementVal);
509+
Py_DECREF(pyElementVal);
510510
return result;
511511
}
512512

@@ -551,7 +551,7 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_repr(JSArrayProxy *self) {
551551
} else {
552552
PyObject *pyElementVal = pyTypeFactory(GLOBAL_CX, elementVal);
553553
s = PyObject_Repr(pyElementVal);
554-
Py_XDECREF(pyElementVal);
554+
Py_DECREF(pyElementVal);
555555
}
556556
if (s == NULL) {
557557
goto error;
@@ -696,10 +696,10 @@ int JSArrayProxyMethodDefinitions::JSArrayProxy_contains(JSArrayProxy *self, PyO
696696
for (index = 0, cmp = 0; cmp == 0 && index < numElements; ++index) {
697697
JS_GetElement(GLOBAL_CX, *(self->jsArray), index, &elementVal);
698698
PyObject *item = pyTypeFactory(GLOBAL_CX, elementVal);
699-
Py_XINCREF(item);
699+
Py_INCREF(item);
700700
cmp = PyObject_RichCompareBool(item, element, Py_EQ);
701-
Py_XDECREF(item);
702-
Py_XDECREF(item);
701+
Py_DECREF(item);
702+
Py_DECREF(item);
703703
}
704704
return cmp;
705705
}
@@ -958,10 +958,10 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_remove(JSArrayProxy *self,
958958
for (Py_ssize_t index = 0; index < selfSize; index++) {
959959
JS_GetElement(GLOBAL_CX, *(self->jsArray), index, &elementVal);
960960
PyObject *obj = pyTypeFactory(GLOBAL_CX, elementVal);
961-
Py_XINCREF(obj);
961+
Py_INCREF(obj);
962962
int cmp = PyObject_RichCompareBool(obj, value, Py_EQ);
963-
Py_XDECREF(obj);
964-
Py_XDECREF(obj);
963+
Py_DECREF(obj);
964+
Py_DECREF(obj);
965965
if (cmp > 0) {
966966
JS::Rooted<JS::ValueArray<2>> jArgs(GLOBAL_CX);
967967
jArgs[0].setInt32(index);
@@ -1024,10 +1024,10 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_index(JSArrayProxy *self,
10241024
for (Py_ssize_t index = start; index < stop && index < selfSize; index++) {
10251025
JS_GetElement(GLOBAL_CX, *(self->jsArray), index, &elementVal);
10261026
PyObject *obj = pyTypeFactory(GLOBAL_CX, elementVal);
1027-
Py_XINCREF(obj);
1027+
Py_INCREF(obj);
10281028
int cmp = PyObject_RichCompareBool(obj, value, Py_EQ);
1029-
Py_XDECREF(obj);
1030-
Py_XDECREF(obj);
1029+
Py_DECREF(obj);
1030+
Py_DECREF(obj);
10311031
if (cmp > 0) {
10321032
return PyLong_FromSsize_t(index);
10331033
}
@@ -1048,10 +1048,10 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_count(JSArrayProxy *self,
10481048
for (Py_ssize_t index = 0; index < length; index++) {
10491049
JS_GetElement(GLOBAL_CX, *(self->jsArray), index, &elementVal);
10501050
PyObject *obj = pyTypeFactory(GLOBAL_CX, elementVal);
1051-
Py_XINCREF(obj);
1051+
Py_INCREF(obj);
10521052
int cmp = PyObject_RichCompareBool(obj, value, Py_EQ);
1053-
Py_XDECREF(obj);
1054-
Py_XDECREF(obj);
1053+
Py_DECREF(obj);
1054+
Py_DECREF(obj);
10551055
if (cmp > 0) {
10561056
count++;
10571057
}
@@ -1097,15 +1097,15 @@ static bool sort_compare_key_func(JSContext *cx, unsigned argc, JS::Value *vp) {
10971097
JS::RootedValue elementVal0(cx, args[0]);
10981098
PyObject *args_0 = pyTypeFactory(cx, elementVal0);
10991099
PyObject *args_0_result = PyObject_CallFunction(keyfunc, "O", args_0);
1100-
Py_XDECREF(args_0);
1100+
Py_DECREF(args_0);
11011101
if (!args_0_result) {
11021102
return false;
11031103
}
11041104

11051105
JS::RootedValue elementVal1(cx, args[1]);
11061106
PyObject *args_1 = pyTypeFactory(cx, elementVal1);
11071107
PyObject *args_1_result = PyObject_CallFunction(keyfunc, "O", args_1);
1108-
Py_XDECREF(args_1);
1108+
Py_DECREF(args_1);
11091109
if (!args_1_result) {
11101110
return false;
11111111
}
@@ -1163,19 +1163,19 @@ static bool sort_compare_default(JSContext *cx, unsigned argc, JS::Value *vp) {
11631163
args.rval().setInt32(reverse ? -1 : 1);
11641164
}
11651165
else {
1166-
Py_XDECREF(args_0);
1167-
Py_XDECREF(args_1);
1166+
Py_DECREF(args_0);
1167+
Py_DECREF(args_1);
11681168
return false;
11691169
}
11701170
}
11711171
else {
1172-
Py_XDECREF(args_0);
1173-
Py_XDECREF(args_1);
1172+
Py_DECREF(args_0);
1173+
Py_DECREF(args_1);
11741174
return false;
11751175
}
11761176

1177-
Py_XDECREF(args_0);
1178-
Py_XDECREF(args_1);
1177+
Py_DECREF(args_0);
1178+
Py_DECREF(args_1);
11791179
return true;
11801180
}
11811181

src/JSObjectIterProxy.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ PyObject *JSObjectIterProxyMethodDefinitions::JSObjectIterProxy_nextkey(JSObject
7979
}
8080

8181
if (self->it.kind != KIND_KEYS) {
82-
Py_XDECREF(value);
82+
Py_DECREF(value);
8383
}
8484

8585
Py_INCREF(ret);
@@ -109,7 +109,7 @@ PyObject *JSObjectIterProxyMethodDefinitions::JSObjectIterProxy_nextkey(JSObject
109109
}
110110

111111
if (self->it.kind != KIND_KEYS) {
112-
Py_XDECREF(value);
112+
Py_DECREF(value);
113113
}
114114

115115
Py_INCREF(ret);

src/JobQueue.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool JobQueue::enqueuePromiseJob(JSContext *cx,
4747

4848
loop.enqueue(callback);
4949

50-
Py_XDECREF(callback);
50+
Py_DECREF(callback);
5151
return true;
5252
}
5353

src/PromiseType.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static bool onResolvedCb(JSContext *cx, unsigned argc, JS::Value *vp) {
4242
#else
4343
PyObject *wrapped = PyObject_CallFunction(SpiderMonkeyError, "O", result); // PyObject_CallOneArg is not available in Python < 3.9
4444
#endif
45-
Py_XDECREF(result);
45+
Py_DECREF(result);
4646
result = wrapped;
4747
}
4848

@@ -58,7 +58,7 @@ static bool onResolvedCb(JSContext *cx, unsigned argc, JS::Value *vp) {
5858
future.setException(result);
5959
}
6060

61-
Py_XDECREF(result);
61+
Py_DECREF(result);
6262
return true;
6363
}
6464

src/PyListProxyHandler.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static bool makeNewPyMethod(JSContext *cx, JS::MutableHandleValue function, JS::
4747
thisValue.setObject(*thisObject);
4848
PyObject *newSelf = pyTypeFactory(cx, thisValue);
4949
function.set(jsTypeFactory(cx, PyMethod_New(func, newSelf)));
50-
Py_XDECREF(newSelf);
50+
Py_DECREF(newSelf);
5151

5252
return true;
5353
}
@@ -114,10 +114,10 @@ static bool array_push(JSContext *cx, unsigned argc, JS::Value *vp) { // surely
114114
elementVal.set(args[index].get());
115115
PyObject *value = pyTypeFactory(cx, elementVal);
116116
if (PyList_Append(self, value) < 0) {
117-
Py_XDECREF(value);
117+
Py_DECREF(value);
118118
return false;
119119
}
120-
Py_XDECREF(value);
120+
Py_DECREF(value);
121121
}
122122

123123
args.rval().setInt32(PyList_GET_SIZE(self));
@@ -166,10 +166,10 @@ static bool array_unshift(JSContext *cx, unsigned argc, JS::Value *vp) { // sure
166166
elementVal.set(args[index].get());
167167
PyObject *value = pyTypeFactory(cx, elementVal);
168168
if (PyList_Insert(self, 0, value) < 0) {
169-
Py_XDECREF(value);
169+
Py_DECREF(value);
170170
return false;
171171
}
172-
Py_XDECREF(value);
172+
Py_DECREF(value);
173173
}
174174

175175
args.rval().setInt32(PyList_GET_SIZE(self));
@@ -281,7 +281,7 @@ static bool array_indexOf(JSContext *cx, unsigned argc, JS::Value *vp) {
281281
JS::RootedValue elementVal(cx, args[0].get());
282282
PyObject *value = pyTypeFactory(cx, elementVal);
283283
PyObject *result = PyObject_CallMethod(self, "index", "Oi", value, start);
284-
Py_XDECREF(value);
284+
Py_DECREF(value);
285285

286286
if (!result) {
287287
PyErr_Clear();
@@ -437,7 +437,7 @@ static bool array_fill(JSContext *cx, unsigned argc, JS::Value *vp) {
437437
}
438438

439439
if (!setItemCalled) {
440-
Py_XDECREF(fillValueItem);
440+
Py_DECREF(fillValueItem);
441441
}
442442

443443
// return ref to self
@@ -568,39 +568,39 @@ static bool array_concat(JSContext *cx, unsigned argc, JS::Value *vp) {
568568
Py_ssize_t itemLength = JSArrayProxyMethodDefinitions::JSArrayProxy_length((JSArrayProxy *)item);
569569
for (Py_ssize_t flatIndex = 0; flatIndex < itemLength; flatIndex++) {
570570
if (!JS_GetElement(cx, *(((JSArrayProxy *)item)->jsArray), flatIndex, &elementVal)) {
571-
Py_XDECREF(item);
571+
Py_DECREF(item);
572572
return false;
573573
}
574574
PyObject *value = pyTypeFactory(cx, elementVal);
575575
if (PyList_Append(result, value) < 0) {
576-
Py_XDECREF(item);
577-
Py_XDECREF(value);
576+
Py_DECREF(item);
577+
Py_DECREF(value);
578578
return false;
579579
}
580-
Py_XDECREF(value);
580+
Py_DECREF(value);
581581
}
582582
}
583583
else if (PyObject_TypeCheck(item, &PyList_Type)) {
584584
// flatten the array only at depth 1
585585
Py_ssize_t itemLength = PyList_GET_SIZE(item);
586586
for (Py_ssize_t flatIndex = 0; flatIndex < itemLength; flatIndex++) {
587587
if (PyList_Append(result, PyList_GetItem(item, flatIndex)) < 0) {
588-
Py_XDECREF(item);
588+
Py_DECREF(item);
589589
return false;
590590
}
591591
}
592592
}
593593
else {
594594
PyObject *value = pyTypeFactory(cx, elementVal);
595595
if (PyList_Append(result, value) < 0) {
596-
Py_XDECREF(item);
597-
Py_XDECREF(value);
596+
Py_DECREF(item);
597+
Py_DECREF(value);
598598
return false;
599599
}
600-
Py_XDECREF(value);
600+
Py_DECREF(value);
601601
}
602602

603-
Py_XDECREF(item);
603+
Py_DECREF(item);
604604
}
605605

606606
args.rval().set(jsTypeFactory(cx, result));
@@ -1313,7 +1313,7 @@ static uint32_t FlattenIntoArray(JSContext *cx,
13131313
targetIndex++;
13141314
}
13151315

1316-
Py_XDECREF(element);
1316+
Py_DECREF(element);
13171317
}
13181318

13191319
return targetIndex;
@@ -1412,7 +1412,7 @@ static uint32_t FlattenIntoArrayWithCallBack(JSContext *cx,
14121412
}
14131413
}
14141414

1415-
Py_XDECREF(element);
1415+
Py_DECREF(element);
14161416
}
14171417

14181418
return targetIndex;

src/PyObjectProxyHandler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ bool PyObjectProxyHandler::set(JSContext *cx, JS::HandleObject proxy, JS::Handle
176176
PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
177177
PyObject *value = pyTypeFactory(cx, rootedV);
178178
if (PyObject_SetAttr(self, attrName, value)) {
179-
Py_XDECREF(value);
179+
Py_DECREF(value);
180180
return result.failCantSetInterposed(); // raises JS exception
181181
}
182-
Py_XDECREF(value);
182+
Py_DECREF(value);
183183
return result.succeed();
184184
}
185185

src/internalBinding/timers.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static bool enqueueWithDelay(JSContext *cx, unsigned argc, JS::Value *vp) {
3232
PyEventLoop loop = PyEventLoop::getRunningLoop();
3333
if (!loop.initialized()) return false;
3434
PyEventLoop::AsyncHandle::id_t handleId = loop.enqueueWithDelay(job, delaySeconds, repeat);
35-
Py_XDECREF(job);
35+
Py_DECREF(job);
3636

3737
// Return the `timeoutID` to use in `clearTimeout`
3838
args.rval().setNumber(handleId);

0 commit comments

Comments
 (0)