From: Steve C. <St...@ig...> - 2002-01-05 14:53:14
|
There is a stack trace and it's the same whether or not showJavaExceptions is true: [scohen@sleepingbear scohen]$ jython -Dpython.options.showJavaExceptions=3Dtrue Jython 2.1 on java1.3.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import dbexts, isql >>> d=3Ddbexts.dbexts("prod_sport") >>> D=3Disql.IsqlCmd(d) >>> D.use_rawinput=3D0 >>> 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 The 1st arg is None, which is arguably a bug in isql.IsqlCmd. 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. Or, if you'd rather have someone more familiar with the internals do it, I certainly understand. -----Original Message----- From: Finn Bock Sent: Sat 1/5/2002 7:44 AM To: jyt...@li... Cc: Steve Cohen Subject: Re: [Jython-users] More fun with Readline [Steve Cohen] >Now that I have readline working with jython, I come quickly to the next >hurdle. Is it possible to integrate readline capabilities into >jython-coded command interpreters based on cmd.Cmd? I cannot get this >to work at all. The docs on cmd.Cmd gave me some hope, but I can't get >any of it to work, not even the Ctrl-P, Ctrl-N stuff. I also tried >setting use_rawinput to 0 to force readline, that produced an error when >I executed cmdloop():=3D20 > >TypeError: write(): 1st arg can't be coerced to String Was there a stacktrace with that exception? It is not uncommon that TypeErrors are caused by a too restrictive method signature in the jython core, but more information is needed. Also try to start jython with the command: jython -Dpython.options.showJavaExceptions=3Dtrue to get additional stacktrace information. >Does anyone have any ideas how readline can be made to work in cmd.Cmd >interpreters? I doubt that it works at the moment. raw_input() just call the .readline() method on sys.stdin. Someone have to add support for readline in __builtin__.raw_input(). Anyone? regards, finn |