Skip to content

Commit

Permalink
test conditional redefine
Browse files Browse the repository at this point in the history
  • Loading branch information
ncullen93 committed May 15, 2024
1 parent 894352a commit 8c7eb86
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/itkPyBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#undef _XOPEN_SOURCE
// For Python 2.7 hypot bug, see https://bugs.python.org/issue11566
//#include "PatchedPython27pyconfig.h"
#if PYTHON_MINOR_VERSION == 12
#define PySequence_FAST_GET_ITEM PySequence_GetItem
#endif
#include <Python.h>

namespace itk
Expand Down
6 changes: 5 additions & 1 deletion src/itkPyBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "itkPyBuffer.h"

#if PYTHON_MINOR_VERSION == 12
#define PySequence_FAST_GET_ITEM PySequence_GetItem
#endif

namespace itk
{

Expand Down Expand Up @@ -112,7 +116,7 @@ PyBuffer<TImage>

for( unsigned int i = 0; i < dimension; ++i )
{
item = PySequence_GetItem(shapeseq,i);
item = PySequence_FAST_GET_ITEM(shapeseq,i);
size[i] = (SizeValueType)PyLong_AsLong(item);
sizeFortran[dimension - 1 - i] = (SizeValueType)PyLong_AsLong(item);
numberOfPixels *= size[i];
Expand Down
3 changes: 3 additions & 0 deletions src/itkPyVnl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
// For Python 2.7 hypot bug, see https://bugs.python.org/issue11566
#if PYTHON_MINOR_VERSION == 12
#define PySequence_FAST_GET_ITEM PySequence_GetItem
#endif
#include <Python.h>
//#include "PatchedPython27pyconfig.h"

Expand Down
8 changes: 6 additions & 2 deletions src/itkPyVnl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#ifndef itkPyVnl_hxx
#define itkPyVnl_hxx

#if PYTHON_MINOR_VERSION == 12
#define PySequence_FAST_GET_ITEM PySequence_GetItem
#endif

#include "itkPyVnl.h"
#include <stdexcept>

Expand Down Expand Up @@ -96,7 +100,7 @@ PyVnl<TElement>
shapeseq = PySequence_Fast(obj, "expected sequence");
dimension = PySequence_Size(obj);

item = PySequence_GetItem(shapeseq,0);// Only one dimension
item = PySequence_FAST_GET_ITEM(shapeseq,0);// Only one dimension
numberOfElements = (size_t)PyLong_AsLong(item);

len = numberOfElements*elementSize;
Expand Down Expand Up @@ -187,7 +191,7 @@ PyVnl<TElement>

for( unsigned int i = 0; i < 2; ++i )
{
item = PySequence_GetItem(shapeseq,i);
item = PySequence_FAST_GET_ITEM(shapeseq,i);
size[i] = (unsigned int)PyLong_AsLong(item);
numberOfElements *= size[i];
}
Expand Down

0 comments on commit 8c7eb86

Please sign in to comment.