[IPython-dev] Status of py3k ipython

MinRK benjaminrk at gmail.com
Mon Oct 4 00:26:06 EDT 2010


On Sun, Oct 3, 2010 at 16:33, Thomas Kluyver <takowl at gmail.com> wrote:

> 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.
>

Thanks for figuring this out, but there are a couple issues.  We actually
need the buffer code to work on *both* Python 2 and 3, so commenting things
out doesn't work.  It does help find the real issues elsewhere, though.
 That file, as it started in mpi4py, works on Pythons 2.3-3.2, but I have
clearly broken some of them when I made my adjustments bringing it into
pyzmq.  I will work these issues out.

As for the PyUnicode instead of PyString: We actually want to enforce
PyBytes in Python 3, not PyUnicode.  It's critically important that pyzmq
never has to deal with Python Unicode objects except through _unicode
convenience methods, due to heinous memory performance issues I won't get
into here (but have gotten into plenty with Brian and Fernando).

Thanks,
-MinRK


>
> 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
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20101003/3fe7dc26/attachment.html>


More information about the IPython-dev mailing list