Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard Py_SET_REFCNT to Python 3.9+ #49

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/c/jpy_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ extern "C" {
#if PY_MINOR_VERSION >= 5
#define JPY_COMPAT_35P 1
#endif
#if PY_MINOR_VERSION >= 9
#define JPY_COMPAT_39P 1
#endif
#undef JPY_COMPAT_27
#else
#error JPY_VERSION_ERROR
Expand Down
6 changes: 5 additions & 1 deletion src/main/c/jpy_jobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,11 @@ int JType_InitSlots(JPy_JType* type)

typeObj = JTYPE_AS_PYTYPE(type);

Py_SET_REFCNT(typeObj, 1);
#if defined(JPY_COMPAT_39P)
Py_SET_REFCNT(typeObj, 1);
#else
Py_REFCNT(typeObj) = 1;
#endif
Py_TYPE(typeObj) = NULL;
Py_SIZE(typeObj) = 0;
// todo: The following lines are actually correct, but setting Py_TYPE(type) = &JType_Type results in an interpreter crash. Why?
Expand Down