Mercurial > pytave
diff python_to_octave.cc @ 328:5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
* oct-py-types.cc, oct-py-types.h (pytave::extract_py_int64): New function.
* python_to_octave.cc (pytave::pyobj_to_octvalue): Convert Python 2 'int' to
Octave int64 type.
* @py/py.m, pycall.cc: Add %!tests for Python 'int' and 'long' type handling,
conditional on Python version.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sat, 13 Aug 2016 23:52:57 -0700 |
parents | 15c20ab4b80a |
children | cee203ea6245 |
line wrap: on
line diff
--- a/python_to_octave.cc Sat Aug 13 21:24:29 2016 -0700 +++ b/python_to_octave.cc Sat Aug 13 23:52:57 2016 -0700 @@ -345,6 +345,10 @@ if (PyBool_Check (py_object.ptr ())) oct_value = boolx (); +#if PY_VERSION_HEX < 0x03000000 + else if (PyInt_Check (py_object.ptr ())) + oct_value = octave_int64 (extract_py_int64 (py_object.ptr ())); +#endif else if (PyFloat_Check (py_object.ptr ())) oct_value = doublex (); else if (PyComplex_Check (py_object.ptr ()))