On 20/05/2013 17:43, Jim Baker wrote:
In Jython 2.5 development, up through 2.5.0 RCs/final, we gave
ourselves the freedom to break existing Java APIs such as
PythonInterpreter. For subsequent 2.5.x releases, we grew the
Java API, but kept it backwards compatible. This required a fair
amount of contortions.
The general principle should continue to stand in 2.7. So you
should feel free to do this refactoring. More below.
I spent a couple of days single-stepping through the initialisation
and making notes. As a result understand this better. I found that
initialisation is really orchestrated by
PySystemState.doInitialize(). I found a spot in the middle of that
where the registry is fully up, but the default PySystemState object
has not yet been created.
I can hook a custom console in at this point that provides a shim to
System.in before sys.stdin gets created on it. I've only tried it
with a do-nothing-much shim:
>>> import sys
>>> print (sys._jy_console, sys.stdin.isatty())
>>> import java.lang.System
The names are temporary while I need old and new approaches
concurrently. I've only sketched a JLine one, and how it would play
with readline.py, but it looks possible.
I believe we still need org.python.util.ReadlineConsole to work: is