Skip to content

Commit 1a414af

Browse files
committed
restore ifdef with 3.12+ function
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent c5230b5 commit 1a414af

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

cpp/csp/python/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <Python.h>
55

66
#define IS_PRE_PYTHON_3_11 (PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 11) )
7+
#define IS_PRE_PYTHON_3_12 (PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 12) )
78
#define IS_PRE_PYTHON_3_13 (PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 13) )
89

910
#define INIT_PYDATETIME if( !PyDateTimeAPI ) { PyDateTime_IMPORT; }

cpp/csp/python/PyNode.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#endif
2222
#include <internal/pycore_code.h>
2323
#include <internal/pycore_frame.h>
24+
#if !IS_PRE_PYTHON_3_13
25+
# undef Py_BUILD_CORE
26+
#endif
2427
#endif
2528

2629
namespace csp::python
@@ -88,7 +91,11 @@ void PyNode::init( PyObjectPtr inputs, PyObjectPtr outputs )
8891
//PY311+ changes
8992
#else
9093
_PyInterpreterFrame * frame = ( _PyInterpreterFrame * ) pygen -> gi_iframe;
94+
#if IS_PRE_PYTHON_3_12
95+
PyCodeObject * code = frame -> f_code;
96+
#else
9197
PyCodeObject * code = PyGen_GetCode( ( PyGenObject * ) pygen );
98+
#endif
9299
int localPlusIndex = 0;
93100
for( int stackloc = code -> co_argcount; stackloc < code -> co_nlocalsplus; ++stackloc, ++localPlusIndex )
94101
{

0 commit comments

Comments
 (0)