JPython org.python.modules Problem
Kevin Howe
khowe at performance-net.com
Wed Jan 12 15:26:55 EST 2000
I found the following thread in the Python Mailing List archives (June 99).
It describes the Jpython problem that I as well as serveral others in the
comp.lang.python newsgroup are having trouble with. It includes details on
how to patch jpython's "jar.py" and "main.py" to fix the problem. I haven't
been able to get the patch to work, I am hoping that someone will be able to
figure this out and post the working version.
ciao,
kh
-------- Patching JPython Thread -----------
>From bwarsaw at cnri.reston.va.us Tue, 8 Jun 1999 18:36:56 -0400 (EDT)
Date: Tue, 8 Jun 1999 18:36:56 -0400 (EDT)
From: Barry A. Warsaw bwarsaw at cnri.reston.va.us
Subject: [JPython] Problems with HelloWorld applet under 1.1
>>>>> "DP" == Darren Platt <daz at exelixis.com> writes:
DP> I installed 1.1 a few days ago and have been trying to get
DP> basic things working, under NT, and the jdk1.2 (after some
DP> nasty jre crashes using jre 1.1.8). To get to the point,
DP> trying to compile a simple HelloWorld applet;
DP> Compiling goes well:
DP> But running the applet under the jdk applet viewer
DP> Gives a traceback:
DP> Looking at the java for the core Jpython code, it refers to
DP> org.python.modules.Setup in org.python.core.PySystemState, and
DP> that code doesn't get included in the jpython.jar and not into
DP> the created hw.jar file, and hence doesn't run :(
DP> Any ideas ?
Yes, that's a bug. Attached is a fix, although I'm not 100%
comfortable with it. Perhaps Setup should be moved to
org.python.core? I'd rather leave it in org.python.modules though...
(I'm still digging into jpythonc so this might change)
-Barry
-------------------- snip snip --------------------
Index: jar.py
===================================================================
RCS file: /projects/cvsroot/jpython/dist/Tools/jpythonc2/jar.py,v
retrieving revision 2.0
diff -c -r2.0 jar.py
*** jar.py 1999/05/19 20:11:59 2.0
--- jar.py 1999/06/08 22:31:00
***************
*** 23,29 ****
--- 23,33 ----
self.entries = []
self.packages = packages
self.manifest = []
+ self.singleclasses = []
+ def addSingleClass(self, class_):
+ self.singleclasses.append(class_)
+
def addFile(self, rootdir, filename):
self.files.append( (rootdir, filename) )
***************
*** 72,83 ****
--- 76,102 ----
for package, skiplist in self.packages:
self.addPackage(package, skiplist)
+ for class_ in self.singleclasses:
+ self.addOneClass(class_)
+
self.dumpManifest()
def dump(self, filename):
self.zipfile = ZipOutputStream(FileOutputStream(filename))
self.dumpFiles()
self.zipfile.close()
+
+ # add just one class from a package
+ def addOneClass(self, pkgclass):
+ parts = pkgclass.split('.')
+ package = string.join(parts[:-1], '.')
+ pkg = lookup(package)
+ filename = os.path.join(pkg.__path__[0], parts[-1]) + '.class'
+ entryname = string.join(parts, '/') + '.class'
+ self.zipfile.putNextEntry(ZipEntry(entryname))
+ instream = FileInputStream(filename)
+ copy(instream, self.zipfile)
+ instream.close()
# The next three methods handle packages (typically org.python.core,
...)
def addPackage(self, package, skiplist=[]):
Index: main.py
===================================================================
RCS file: /projects/cvsroot/jpython/dist/Tools/jpythonc2/main.py,v
retrieving revision 2.2
diff -c -r2.2 main.py
*** main.py 1999/06/08 20:14:28 2.2
--- main.py 1999/06/08 22:29:58
***************
*** 158,164 ****
if options.jar is not None:
options.deep = 1
elif options.core or options.all:
! opts.deep = 1
if not os.path.isabs(options.workdir):
options.workdir = os.path.join(".", options.workdir)
--- 158,164 ----
if options.jar is not None:
options.deep = 1
elif options.core or options.all:
! options.deep = 1
if not os.path.isabs(options.workdir):
options.workdir = os.path.join(".", options.workdir)
***************
*** 265,270 ****
--- 265,273 ----
for dep in comp.trackJavaDependencies():
ja.addEntry(dep)
+
+ if opts.core or opts.all:
+ ja.addSingleClass('org.python.modules.Setup')
ja.dump(jarfile)
More information about the Python-list
mailing list