Skip to content

Commit

Permalink
Fixup int handling changes.
Browse files Browse the repository at this point in the history
In Python 2, we still need to allow for the possibility that a Python
integer may be PyInt_Type instead of PyLong_Type.
  • Loading branch information
TallJimbo authored and timj committed Aug 5, 2016
1 parent 74d522a commit 8d708f9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions include/ndarray/swig/PyConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ template <>
struct PyConverter<int> : public detail::PyConverterBase<int> {

static bool fromPythonStage1(PyPtr & input) {
if (!PyLong_Check(input.get()) && !PyLong_Check(input.get())) {
if (
#if PY_MAJOR_VERSION <= 2
!PyInt_Check(input.get()) &&
#endif
!PyLong_Check(input.get())
) {
PyPtr s(PyObject_Repr(input.get()));
if (!s) return false;
char * cs = PyBytes_AsString(s.get());
Expand All @@ -224,7 +229,12 @@ template <>
struct PyConverter<long> : public detail::PyConverterBase<long> {

static bool fromPythonStage1(PyPtr & input) {
if (!PyLong_Check(input.get()) && !PyLong_Check(input.get())) {
if (
#if PY_MAJOR_VERSION <= 2
!PyInt_Check(input.get()) &&
#endif
!PyLong_Check(input.get())
) {
PyPtr s(PyObject_Repr(input.get()));
if (!s) return false;
char * cs = PyBytes_AsString(s.get());
Expand Down

0 comments on commit 8d708f9

Please sign in to comment.