From: Finn B. <bc...@us...> - 2001-03-13 20:27:43
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv28961 Modified Files: os.java Log Message: Reworked import mechanisme. Mostly to ensure that javaos.__doc__ gets imported into the os module. Index: os.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/os.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** os.java 2001/02/07 09:26:19 2.5 --- os.java 2001/03/13 20:29:42 2.6 *************** *** 9,22 **** // An ugly hack, but it keeps the site.py from CPython2.0 happy - public static String __file__; - public static void classDictInit(PyObject dict) { - String prefix = Py.getSystemState().prefix; - if (prefix != null) - __file__ = prefix + "/Lib/javaos.py"; // Fake from javaos import * ! PyFrame frame = new PyFrame(null, dict, dict, null); ! org.python.core.imp.importAll("javaos", frame); } } --- 9,31 ---- // An ugly hack, but it keeps the site.py from CPython2.0 happy public static void classDictInit(PyObject dict) { // Fake from javaos import * ! ! PyTuple all = new PyTuple(new PyString[] { Py.newString('*') }); ! PyObject module = __builtin__.__import__("javaos", null, null, all); ! ! PyObject names = module.__dir__(); ! PyObject name; ! for (int i = 0; (name=names.__finditem__(i)) != null; i++) { ! String sname = name.toString().intern(); ! dict.__setitem__(name, module.__getattr__(sname)); ! } ! ! String prefix = Py.getSystemState().prefix; ! if (prefix != null) { ! String libdir = prefix + "/Lib/javaos.py"; ! dict.__setitem__("__file__", new PyString(libdir)); ! } } } |