<br><br><div class="gmail_quote">On Fri, Oct 22, 2010 at 18:30, Jim Baker <span dir="ltr"><<a href="mailto:jbaker@zyasoft.com">jbaker@zyasoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div><div></div><div class="h5">On Fri, Oct 22, 2010 at 5:35 PM, Thomas Kluyver <span dir="ltr"><<a href="mailto:takowl@gmail.com" target="_blank">takowl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="gmail_quote">On 23 October 2010 00:04, <span dir="ltr"><<a href="mailto:ipython-dev-request@scipy.org" target="_blank">ipython-dev-request@scipy.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div>Trying a little bit more by disabling that version check, I discovered that<br>
at least 2.6's support of print as a function, instead of a statement, is<br>
used. Now Jython 2.6 work kicked off just this week, so hopefully we don't<br>
really need 2.6. Jython 2.5 does have two key 2.6 features that you might be<br>
using: 1) full mutable ast support (through the ast module, used by sympy's<br>
support); 2) class decorators. (We also have namedtuple.)<br>
<br>
Maybe for Jython this is just a matter of isolating the print function? It<br>
doesn't seem to be used in too many places.</div></blockquote></div><br></div>Just to chime in here, we have been working on the principle that ipython 0.11 would depend on Python 2.6 or later, and I've been 'modernising' the code base a bit, to fit in with my Python 3 branch of ipython. I'm sorry if this makes your life harder. Off the top of my head, though, I think most if not all of my changes should be compatible with 2.5.<br>
</blockquote></div></div></div></blockquote><div><br></div><div>One 'modern' codestyle that is not compatible with 2.5:</div><div>try:</div><div> stuff()</div><div>except Exception as e:</div><div> handle(e)</div>
<div><br></div><div>That's invalid on 2.5, but 'except Exception, e:' is invalid on 3.x.</div><div><br></div><div>The only method that I have discovered that works on both is:</div><div><br></div><div>try:</div>
<div> stuff()</div><div>except Exception:</div><div> e = sys.exc_info()[1]</div><div><br></div><div>Obviously not as elegant as either one, but if you are supporting 2.5 and 3.1, it's the only way that works that I know of.</div>
<div>That's what I do in my 'nowarn' branch of pyzmq, which works (as of yesterday) on everything from 2.5-3.1 with no code changes.</div><div><br></div><div>-MinRK</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote><div><br></div></div></div><div>Sounds reasonable to have a small compatibility shim then for 2.5. The other piece I've found so far is switching from compiler to _ast (assuming CPython 2.5 compliance of course); neither Python 3 nor Jython supports the old-style syntax tree. Casually inspecting the usage of the compiler module suggests that there's not much use. In core, kernel.core.interpreter and core.inputsplitter seem to have significant code duplication in their use of compiler to get line numbers. We do support codeop, so that should work as soon as it's made valid for future imports.</div>
<div><br></div><div>Incidentally the problem I noticed earlier in parsing a statement like "print 42" was with codeop.CommandCompiler, not the compiler module. Apparently ipython expects CPython's behavior of codeop.CommandCompiler().compiler.flags, which is an int, whereas Jython has this as codeop.CommandCompiler()._cflags, which is a structure. Strange, I thought this was being exposed as an int for compatibility in this fashion. Maybe we should fix that part for 2.5.2rc2. I'll take a look at it.</div>
<div><br></div><div>- Jim</div><div><br></div></div>
<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br>