Mercurial > pytave
changeset 272:1446812ec1de
Merged in genuinelucifer/pytave_main (pull request #29)
Convert numeric value to long instead of int to avoid overflow (fixes issue #40)
author | Mike Miller <mike@mtmxr.com> |
---|---|
date | Fri, 29 Jul 2016 13:33:56 -0700 |
parents | 2cb6e2824776 (current diff) 0a4f620da178 (diff) |
children | ecca6a885ffd |
files | pyeval.cc |
diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pyeval.cc Fri Jul 29 13:09:47 2016 -0700 +++ b/pyeval.cc Fri Jul 29 13:33:56 2016 -0700 @@ -141,6 +141,11 @@ %!assert (isa (pyeval ("object()"), "pyobject")) +%!assert (isnumeric (pyeval ("sys.maxsize"))) +%!assert (isnumeric (pyeval ("-sys.maxsize"))) +%!assert (pyeval ("99999999999999"), 99999999999999) +%!assert (pyeval ("-99999999999999"), -99999999999999) + ## FIXME: these will change when dict, list, and tuple are not converted %!assert (pyeval ("{'x': 1, 'y': 2}"), struct ("x", 1, "y", 2)) %!assert (pyeval ("[1, 2, 3]"), {1, 2, 3})
--- a/python_to_octave.cc Fri Jul 29 13:09:47 2016 -0700 +++ b/python_to_octave.cc Fri Jul 29 13:33:56 2016 -0700 @@ -477,7 +477,7 @@ void pyobj_to_octvalue (octave_value& oct_value, const boost::python::object& py_object) { - extract<int> intx (py_object); + extract<long> longx (py_object); extract<bool> boolx (py_object); extract<double> doublex (py_object); extract<Complex> complexx (py_object); @@ -490,8 +490,8 @@ if (boolx.check () && PyBool_Check ((PyArrayObject*)py_object.ptr ())) oct_value = boolx (); - else if (intx.check ()) - oct_value = intx (); + else if (longx.check ()) + oct_value = longx (); else if (doublex.check ()) oct_value = doublex (); else if (complexx.check ())