Hi all,
I'm experiencing a very strange problem when running ns3's python bindings in an ipython REPL. Specifically, the results of an out-of-bounds access are different than in a regular python REPL.
Here's regular python:
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ns.core
>>> import ns.network
>>> nodes = ns.network.NodeContainer()
>>> nodes.Create(2)
>>> z = nodes.Get(3)
>>> z is None
True
As expected, the invalid index to Get() returns None. However, in ipython:
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import ns.network
In [2]: import ns.core
In [3]: nodes = ns.network.NodeContainer()
In [4]: nodes.Create(2)
In [5]: z = nodes.Get(3)
In [6]: z is None
Out[6]: False
In [7]: z
Out[7]: <network.Node at 0x108a173f8>
In [8]: y = nodes.Get(1)
In [9]: y
Out[9]: <network.Node at 0x108a173f8> # same address?
In [10]: x = nodes.Get(0)
In [11]: x
Out[11]: <network.Node at 0x108a17ab8> # different address, as expected.
The reason I have to assign to variables is that when I don't, the call to nodes.Get(3) causes ipython to segfault.
I accept that this is likely an ipython issue, but I'm puzzled as to why I'd get different results from the call to nodes.Get(). Has anyone run into this before? (Can anyone else reproduce the issue?)
Also just FYI, using jupyter-console, I get a segfault with the above code.
Thanks.