[IPython-dev] Status of py3k ipython

Thomas Kluyver takowl at gmail.com
Sun Oct 3 19:33:18 EDT 2010


On 3 October 2010 21:43, Fernando Perez <fperez.net at gmail.com> wrote:

> Hi Thomas,
>
> Very interesting...  In fact, the twisted dependency shouldn't matter
> *at all* for the ipython-qtconsole code, that code uses strictly zmq
> and has no twisted dependency:
>

Hmm, interesting. I'd tried to import IPython.kernel in a shell session, and
it fell over trying to import twisted, so I assumed that the frontend code
needed the kernel code.

What it does: The Qt app starts up, and I get the banner message printed
(Python version, copyright etc., IPython version, pointers to help systems).
There's enough blank space that I can just scroll down to show a blank view.
However, there's no prompt of any sort, and typing doesn't seem to do
anything. At the terminal where I started it, I see some KSharedDataCache
messages (related to icons--I'm running KDE), "Starting the kernel at...",
details of four channels, and "To connect another client...".  There were
previously some error messages at the terminal too, but I tracked them down
and fixed them easily enough.

And getting any fixes you may have made back into pyzmq would be great.
> All of the pyzmq/ipython-zmq code is brand new, so the earlier we
> catch any py3-noncompliance, the better off we'll be.
>

You can see my changes at http://github.com/takowl/pyzmq/tree/py3zmq (look
particularly at this commit, after I'd realised that I should change the
.pyx files, not the .c files:
http://github.com/takowl/pyzmq/commit/8261e19189c6733f312e248bf77ee485286634d8).

In particular, there are a couple of places where you test for Python 3 to
decide how to do something. When this is converted to C and compiled, the
compiler can't find the relevant symbols for the Python 2 alternative. I
don't know if Cython allows you to do the equivalent of C preprocessor code,
so to get it working, I just commented out the Python 2 sections.

For the change to Cython that's needed at present, see the attached patch.

 When ipython exits the only code that is meant to run is whatever we
> registered via atexti().  Just grep for atexit and you'll find those.
>
> But the real problem is not what happens to ipython, but to the
> *python* interpreter.  When *that* is truly being shut down (i.e.
> after atexit calls happen, which occur while the interpreter is still
> intact and fully operational), then various objects (including modules
> and possibly builtins) start getting torn down and may be in
> inconsistent state.  So __del__ calls that attempt to make use of
> other machinery may well find themselves trying to call things that
> have become None, and thus blow up.
>

Well, atexit triggers .reset() of the InteractiveShell object, which looks
like it should delete locally created variables. And it does; I've just
tried that a=A() example, and calling ip.reset() gives me the same "ignored"
NameError as exiting the shell. Which is odd, because if I manually do the
first step in .reset, clear()-ing each dictionary in .ns_refs_table, the
"object A deleted" message pops out flawlessly. Thanks for the information,
although I still can't work out exactly where the problem is.

For what it's worth, I did try running the same snippet of code in plain
python 3.1, and it works as it should.

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20101004/66947395/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cython_PyUnicode.patch
Type: application/octet-stream
Size: 671 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20101004/66947395/attachment.obj>


More information about the IPython-dev mailing list