Skip to content

Commit

Permalink
free pylist strong references at the end
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Dec 4, 2024
1 parent 2c9165b commit bf60294
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/packages/Python.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ module Python {
const idx = res.domain.orderToIndex(i);
var elm = PySequence_GetItem(obj, i);
this.checkException();
defer Py_DECREF(elm);
this.toFree.pushBack(elm);
res[idx] = fromPython(res.eltType, elm);
this.checkException();
}
Expand All @@ -666,7 +666,7 @@ module Python {
for i in 0..<PySequence_Size(obj) {
var item = PySequence_GetItem(obj, i);
this.checkException();
defer Py_DECREF(item);
this.toFree.pushBack(item);
res.pushBack(fromPython(T.eltType, item));
}
return res;
Expand All @@ -676,7 +676,7 @@ module Python {
while true {
var item = PyIter_Next(obj);
this.checkException();
defer Py_DECREF(item);
this.toFree.pushBack(item);
if item == nil {
break;
}
Expand Down

0 comments on commit bf60294

Please sign in to comment.