From: brian z. <bz...@zi...> - 2002-01-07 04:37:18
|
Steve, The majority of the python modules in Lib are copied from the same version of the CPython distribution. Only when the module is new and jython-centric (jreload, dbexts) or drastically differs (string, socket) does it get checked into Jython's CVS. For both development and production, I point at the current Jython Lib and then the same version of CPython's Lib. This makes sure I pick any Jython specific modules first before trying to load the standard Python distribution's modules. For something like cmd.py, it's probably best to work with the CPython version and submit your patch there along with the explanation for why it is needed. Some CPython modules check for os.name == 'java' (unittest) and do something accordingly. Along this note, there was a change to string.py in CPython 2.2 that includes three attributes not found in the Jython version currently in CVS: # not set to 'lowercase' or 'uppercase' because they can change ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ascii_letters = ascii_lowercase + ascii_uppercase Without them, the 2.2 version of cmd.py from (CPython) will not work when imported from Jython 2.1+. I'm going to raise a bug and provide the patch but you can paste these in your local Jython version of string.py in the interim. Hope this helps. brian > -----Original Message----- > From: Steve Cohen > [mailto:jyt...@li...] On Behalf > Of Steve Cohen > Sent: Sunday, January 06, 2002 9:58 PM > To: Steve Cohen; Finn Bock; jyt...@li... > Subject: RE: [Jython-users] More fun with Readline > > > 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. > > 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. > > > -----Original Message----- > From: Steve Cohen on behalf of Steve Cohen > Sent: Sat 1/5/2002 6:28 PM > To: Finn Bock; jyt...@li... > Cc: > 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=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 > > 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. > > 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. > > >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 > > > > |