Skip to content

Commit

Permalink
Add JPy_XINCREF and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Sep 23, 2024
1 parent e36c55b commit d50b1e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/c/jni/org_jpy_PyLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ JNIEXPORT jobject JNICALL Java_org_jpy_PyLib_getCurrentGlobals

#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 12
globals = PyEval_GetGlobals(); // borrowed ref
JPy_INCREF(globals);
JPy_XINCREF(globals);
#else
// See https://peps.python.org/pep-0667 for the change in Python 3.13
globals = PyEval_GetFrameGlobals(); // new ref
Expand Down Expand Up @@ -590,7 +590,7 @@ JNIEXPORT jobject JNICALL Java_org_jpy_PyLib_getCurrentLocals

#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 12
locals = PyEval_GetLocals(); // borrowed ref
JPy_INCREF(locals);
JPy_XINCREF(locals);
#else
// See https://peps.python.org/pep-0667 for the change in Python 3.13
locals = PyEval_GetFrameLocals(); // new ref
Expand Down
1 change: 1 addition & 0 deletions src/main/c/jpy_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern "C" {
#if 1
#define JPy_DECREF(x) Py_DECREF(x)
#define JPy_INCREF(x) Py_INCREF(x)
#define JPy_XINCREF(x) Py_XINCREF(x)
#define JPy_XDECREF(x) Py_XDECREF(x)
#else
#include "jpy_diag.h"
Expand Down

0 comments on commit d50b1e1

Please sign in to comment.