From: Finn B. <bc...@us...> - 2000-12-11 18:45:28
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv31118 Modified Files: codecs.java imp.java Log Message: Use the __import__ API in __builtin__. Index: codecs.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/codecs.java,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** codecs.java 2000/10/17 19:14:19 2.2 --- codecs.java 2000/12/11 18:45:25 2.3 *************** *** 78,82 **** import_encodings_called = true; try { ! imp.importName("encodings", true); } catch (PyException exc) { if (exc.type != Py.ImportError) --- 78,82 ---- import_encodings_called = true; try { ! __builtin__.__import__("encodings"); } catch (PyException exc) { if (exc.type != Py.ImportError) Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** imp.java 2000/11/20 21:57:37 2.31 --- imp.java 2000/12/11 18:45:25 2.32 *************** *** 494,505 **** public static void importOne(String mod, PyFrame frame) { //System.out.println("importOne(" + mod + ")"); ! PyObject module = getImportFunc(frame).__call__( ! new PyObject[] { ! Py.newString(mod), ! frame.f_globals, ! frame.f_locals, ! Py.EmptyTuple ! }); ! int dot = mod.indexOf('.'); if (dot != -1) { --- 494,501 ---- public static void importOne(String mod, PyFrame frame) { //System.out.println("importOne(" + mod + ")"); ! PyObject module = __builtin__.__import__(mod, ! frame.f_globals, ! frame.f_locals, ! Py.EmptyTuple); int dot = mod.indexOf('.'); if (dot != -1) { *************** *** 516,527 **** public static void importOneAs(String mod, String asname, PyFrame frame) { //System.out.println("importOne(" + mod + ")"); ! PyObject module = getImportFunc(frame).__call__( ! new PyObject[] { ! Py.newString(mod), ! frame.f_globals, ! frame.f_locals, ! getStarArg() ! }); ! frame.setlocal(asname, module); } --- 512,519 ---- public static void importOneAs(String mod, String asname, PyFrame frame) { //System.out.println("importOne(" + mod + ")"); ! PyObject module = __builtin__.__import__(mod, ! frame.f_globals, ! frame.f_locals, ! getStarArg()); frame.setlocal(asname, module); } *************** *** 550,560 **** pynames[i] = Py.newString(names[i]); ! PyObject module = getImportFunc(frame).__call__( ! new PyObject[] { ! Py.newString(mod), ! frame.f_globals, ! frame.f_locals, ! new PyTuple(pynames) ! }); for (int i=0; i<names.length; i++) { PyObject submod = module.__findattr__(names[i]); --- 542,549 ---- pynames[i] = Py.newString(names[i]); ! PyObject module = __builtin__.__import__(mod, ! frame.f_globals, ! frame.f_locals, ! new PyTuple(pynames)); for (int i=0; i<names.length; i++) { PyObject submod = module.__findattr__(names[i]); *************** *** 579,587 **** public static void importAll(String mod, PyFrame frame) { //System.out.println("importAll(" + mod + ")"); ! PyObject module = getImportFunc(frame).__call__(new PyObject[] { ! Py.newString(mod), ! frame.f_globals, ! frame.f_locals, ! getStarArg() } ); PyObject names; if (module instanceof PyJavaPackage) names = ((PyJavaPackage)module).fillDir(); --- 568,575 ---- public static void importAll(String mod, PyFrame frame) { //System.out.println("importAll(" + mod + ")"); ! PyObject module = __builtin__.__import__(mod, ! frame.f_globals, ! frame.f_locals, ! getStarArg()); PyObject names; if (module instanceof PyJavaPackage) names = ((PyJavaPackage)module).fillDir(); *************** *** 591,595 **** } ! // if __all__ is present, things work properly under the assumption that names is sorted (__*__ names come first) private static void loadNames(PyObject names, PyObject module, PyObject locals) --- 579,584 ---- } ! // if __all__ is present, things work properly under the assumption ! // that names is sorted (__*__ names come first) private static void loadNames(PyObject names, PyObject module, PyObject locals) *************** *** 651,666 **** modules.__setitem__(modName, ret); return ret; - } - - private static PyObject __import__ = null; - - private static PyObject getImportFunc(PyFrame frame) { - if (__import__ == null) - __import__ = Py.newString("__import__"); - // Set up f_builtins if not already set - PyObject builtins = frame.f_builtins; - if (builtins == null) - builtins = Py.getSystemState().builtins; - return builtins.__getitem__(__import__); } } --- 640,643 ---- |