From: Steve C. <St...@ig...> - 2002-01-07 03:57:48
|
Well, I developed what I thought was a nice integration of readline into cmd.py. It worked perfectly and it made no assumptions about the presence or absence of readline. =20 I started preparing a patch file. It involved a few of the java classes and cmd.py. All was going well and then I noticed that cmd.py was NOT in CVS. Where did it come from then? It must have come from the installation. From the docs I see that it may have come originally from CPython. OK, so what does this mean? Does it mean that my changes also have to work in CPython? I'm confused.=20 -----Original Message----- From: Steve Cohen on behalf of Steve Cohen Sent: Sat 1/5/2002 6:28 PM To: Finn Bock; jyt...@li... Cc:=09 Subject: RE: [Jython-users] More fun with Readline OK. On one level getting cmd.Cmd to use the readline is easy. Just import org.gnu.readline.Readline and I'm on my way. It works exactly as I want it to work. But of course, that won't do, since org.gnu.readline is optional. What I'd like to do is somehow grab the "interp" InteractiveConsole that is created in jython.main() and call IT'S raw_input method. But I don't see a way to do this. interp is a local variable to the main method. Is there some behind the scenes way I can hook this, to take advantage of its readline capabilities? That seems like the "right" way to do this, but is there a way to do it short of modifying jython.java? Seems kind of an extreme step for my first attempt to fix something in jython. -----Original Message----- From: Finn Bock Sent: Sat 1/5/2002 4:11 PM To: jyt...@li... Cc: Steve Cohen Subject: Re: [Jython-users] More fun with Readline [Steve Cohen] >There is a stack trace and it's the same whether or not >showJavaExceptions is true: That is OK. Thanks. >[scohen@sleepingbear scohen]$ jython >-Dpython.options.showJavaExceptions=3D3Dtrue >Jython 2.1 on java1.3.0 (JIT: null) >Type "copyright", "credits" or "license" for more information. >>>> import dbexts, isql >>>> d=3D3Ddbexts.dbexts("prod_sport") >>>> D=3D3Disql.IsqlCmd(d) >>>> D.use_rawinput=3D3D0 >>>> D.cmdloop() >Traceback (innermost last): > File "<console>", line 1, in ? > File "/usr/local/jython/jython-2.1/Lib/cmd.py", line 79, in cmdloop >TypeError: write(): 1st arg can't be coerced to String Not quite the error situation that I expected, but that just goes to show how important the context is. I have added a bug report about the situation. >The 1st arg is None, which is arguably a bug in isql.IsqlCmd.=20 Are you absolutely sure that self.prompt is None. AFAICT D.prompt should be an instance of the Prompt class and that will cause the stacktrace above. A None value will cause a NPE which is a different bug. Please recheck the value of D.prompt. >The code >in cmdloop can't handle it (can't coerce it to String). I can work >around the bug by explicitly setting D.prompt (which is the first >argument passed in) before executing D.cmdloop() but then you are quite >right, there still isn't support for any form of readline, either the >java_readline that is in the interactive mode or even the Ctrl-N, Ctrl-P >stuff that the documentation speaks of. > >I suppose I could take a look at fixing this, although I'm not extremely >familiar with it. If you could point me to where the java_readline >stuff is integrated into the interactive mode, I could have a go at it. That code is located in org\python\util\ReadlineConsole.java.=20 >Or, if you'd rather have someone more familiar with the internals do it, >I certainly understand. Well, I prefer that it is implemented by someone who really want it to work. If you decide to try, feel free to ask questions and seek advice on jython-dev. regards, finn |