Mercurial > pytave
comparison @py/py.m @ 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 | 16bf288f25ad |
children | fe6b9e618c98 |
comparison
equal
deleted
inserted
replaced
327:15c20ab4b80a | 328:5782d7932529 |
---|---|
26 p = class (struct (), "py"); | 26 p = class (struct (), "py"); |
27 endfunction | 27 endfunction |
28 | 28 |
29 %!assert (py.math.sqrt (2), sqrt (2)) | 29 %!assert (py.math.sqrt (2), sqrt (2)) |
30 %!assert (ischar (py.sys.version)) | 30 %!assert (ischar (py.sys.version)) |
31 | |
32 %!test | |
33 %! if (double (py.sys.hexversion) >= 0x03000000) | |
34 %! assert (isobject (py.int (0))) | |
35 %! else | |
36 %! assert (py.int (0), int64 (0)) | |
37 %! endif | |
38 | |
39 %!test | |
40 %! if (double (py.sys.hexversion) < 0x03000000) | |
41 %! assert (py.int (2147483647), int64 (2147483647)) | |
42 %! endif | |
43 | |
44 %!test | |
45 %! if (double (py.sys.hexversion) < 0x03000000) | |
46 %! assert (isobject (py.long (0))) | |
47 %! endif | |
48 | |
49 %!test | |
50 %! if (double (py.sys.hexversion) >= 0x03000000) | |
51 %! assert (isobject (py.int (2^100))) | |
52 %! else | |
53 %! assert (isobject (py.long (2^100))) | |
54 %! endif |