[IPython-user] 0.4.0 ready for Monday
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Fri May 16 22:17:46 CDT 2003
>>>>> "FP" == Fernando Perez <fperez at colorado.edu> writes:
FP> Hi all, I think 0.4.0 is ready for release, so I'll put it out
FP> on Monday barring any last-minute show-stoppers. It's
FP> basically 0.2.15pre4 with a few small things, and two
FP> important fixes:
Last evening my advisor pointed to me a problem with IPython and a
SWIG wrapped module. Global variables in C are wrapped by swig and
put in an object called cvar that behaves in what might be considered
un-pythonic fashion. Here is an example of what happens:
$ cd SWIG-1.3.19/Examples/python/variables
# ipython
IPython 0.2.15pre3 -- An enhanced Interactive Python.
In [1]: import example
In [2]: example.cvar [Return]
Testing sys.sdtout... OK.
Testing sys.sdterr...OK.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
[...]
NameError: Unknown C global variable
WARNING:
The above exception has been trapped by IPython's 'last line of defense'.
[...]
However something like this works:
$ python
import exaPython 2.2.1 (#1, Sep 7 2002, 14:34:30)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
mple
>>> import example
>>> example.cvar [Return]
Global variables { path, status, pt, ptptr, name, iptrvar, cstrvar, strvar, dvar, fvar, cvar, ucvar, scvar, ulvar, usvar, uivar, lvar, svar, ivar }
>>>
Besides this also works:
ipython
In [1]: import example
In [2]: example.cvar.path
Out[2]: '/home/beazley'
I think the problem is that the exception raised by accessing
example.cvar.foo is a NameError and not an AttributeError. This
triggers the IPython crash since the exception is not trapped.
>>> example.cvar.foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: Unknown C global variable
I have the crash report and am attaching it below. I am not sure this
is an IPython bug or a swig bug. If you are sure that its not an
IPython bug I'll let the SWIG developers know.
Thanks and sorry for being a spoil sport. ;-(
prabhu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IPython_crash_report.txt
Type: application/octet-stream
Size: 13905 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/ipython-user/attachments/20030517/d7373396/attachment.obj
More information about the IPython-user
mailing list