From: <bc...@wo...> - 2000-11-09 14:46:44
|
[Samuele Pedroni] >Basically I have finished the tentative (open for discussion) patch/rewr. >for loading precedence and merging the PyJava*Package classes. >(I have setup also some hooks in PackageManager impl. and PyJavaPackage >for the future load sets). >I have to test it and then it will appear here. > >I have some questions on assumptions I have made: > >(I) For use as a 1st arg to a two args File ctr, an empty string is always >explicitly expanded in jython codebase, sometimes with > if( dir.equals("") ) dir="."; >sometimes with > if( dir.equals("") ) dir=<the value of System.getProperty("user.dir")>; >The two methods should be aquivalent, does someone know how could they >be different? which one should be preferred? >(e.g. are there problems with the first method on a Mac jvm?) I think it would be better to let the File() ctor create and handle the aspect of relative files. I.e. if (dirName.length() == 0) dirName = null; File dir = new File(dirName, name); It is not well defined, what will happen if the dirName == "", but a null directory value will create a relative file. Clearly both imp.loadFromPath and BytecodeLoader.open should use the same algorithm. That they doesn't just show that noone have had the Big Picture. >(II) a) I have fixed (I hope) the relative import in package modules bug >(runtime side, not jythonc yet), >I had to rewrite the three args imp.importName was code dealt only with >relative module import and not packages and was buggy wrt. to the top flag, > >the runtime enforce and the old code assumed that if x.y.z is a key in >sys.modules (x.y.z loaded) also any subseq (e.g. x,x.y) will be present as a key >in sys.modules. >I have used that assumption too, and took care that the runtime enforce its >validity. Any one sees problem with that? No. From my understanding that is what sys.modules should contain. >b) Is the following correct for CPython?, I have tryed to enforce it also >in jython: > >p0,p1 are py packages > >if I do the following in a p1.a module: > > import sys > import p0.a.b.x > from p0.a.b.y import val > >the keys p1.sys and p1.p0 will be added to sys.modules with value None. >But no key of the form p1.p0.a... etc. (clearly the plain keys p0... and sys, >binding to the real modules will be added too). That is indeed what CPython does. From the source, the None values appears to some kind of optimizations, inserted just to show that these module names does not exists. But it is difficult to be sure, the dotted-import source code in CPython is not much better than Jython's. regards, finn |