Skip to content

Commit

Permalink
incref none
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Jan 17, 2025
1 parent 9fbd1a1 commit e03262d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tools/chapel-py/src/core-types-gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ struct InvokeHelper<void(Args...)> {
template <typename F>
static PyObject* invoke(ContextObject* contextObject, F&& fn) {
fn();
Py_RETURN_NONE;
// In python3.12, Py_None is immortal and this is not needed
Py_INCREF(Py_None);
return Py_None;
}
};

Expand Down
8 changes: 6 additions & 2 deletions tools/chapel-py/src/python-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ PyObject* wrapOptional(ContextObject* context, const std::optional<T>& opt) {
if (opt) {
return PythonReturnTypeInfo<T>::wrap(context, *opt);
} else {
Py_RETURN_NONE;
// In python3.12, Py_None is immortal and this is not needed
Py_INCREF(Py_None);
return Py_None;
}
}

Expand Down Expand Up @@ -211,7 +213,9 @@ PyObject* wrapNilable(ContextObject* context, const Nilable<T>& opt) {
if (opt.value) {
return PythonReturnTypeInfo<T>::wrap(context, opt.value);
} else {
Py_RETURN_NONE;
// In python3.12, Py_None is immortal and this is not needed
Py_INCREF(Py_None);
return Py_None;
}
}

Expand Down

0 comments on commit e03262d

Please sign in to comment.